Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL syntax error when using MySQL #64

Closed
evgenyneu opened this issue May 14, 2012 · 6 comments
Closed

SQL syntax error when using MySQL #64

evgenyneu opened this issue May 14, 2012 · 6 comments

Comments

@evgenyneu
Copy link

If using MySQL database instead of PostrgeSQL it shows an error when opening the newly created project in browser:

ActiveRecord::StatementInvalid in Projects#show

Showing /home/evgeny/code/tmp/copycopter-server/app/views/projects/show.html.erb where line #4 raised:

Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key ASC' at line 1: SELECT `locales`.* FROM `locales`  WHERE `locales`.`project_id` = 1 AND `locales`.`enabled` = 1 ORDER BY key ASC

Is copycopter-server supposed to support MySQL?

@darpanp
Copy link

darpanp commented May 15, 2012

I had the same issue when using MySQL database. I modified the following code to fix this issue.

In .../copycopter-server/app/views/projects/show.html.erb where line #4 is
<% @project.locales.enabled_in_order.each do |locale| -%>

Modify to
<% @project.locales.each do |locale| -%>

@darpanp
Copy link

darpanp commented May 20, 2012

@evgenyneu,
I played around with MySQL a little bit more. There were additional issues with the UPDATE so I modified some underlying queries. Seems to be working fine on my local. If you are interested in the changes, let me know.

@evgenyneu
Copy link
Author

@darpanp thank you, yes it would be nice if you could share your changes.

@darpanp
Copy link

darpanp commented May 21, 2012

Make following changes to app/models/localization.rb. This should allow you to publish blurbs to all environments (i.e. publish after selecting Production instead of Draft). Oh and don't forget the aforementioned fix above.

Let me know how this works for you.

=========== CODE CHANGES ==================

def self.latest_version
#MYSQL
<<-eosql
SELECT DISTINCT localization_id, id, content
FROM versions ORDER BY localization_id DESC, id DESC
eosql
end

def self.publish
#MYSQL
ActiveRecord::Base.connection.execute <<-eosql
UPDATE localizations
INNER JOIN (
#{latest_version}
) latest_version
ON localizations.id = latest_version.localization_id
SET published_version_id = latest_version.id,
published_content = latest_version.content,
updated_at = '#{connection.quoted_date(Time.now)}'
WHERE localizations.id IN (#{scoped.map(&:id).join(',')});
eosql
end

@patricksrobertson
Copy link
Contributor

copycopter-server wasn't designed to support MySQL. I'm personally not enthused about supporting it either. Not saying I won't look to improve cross-DB compatibility though.

@patricksrobertson
Copy link
Contributor

Duplicate to #66

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants