0

$ Customer.send("today").count

 SELECT COUNT(*) FROM "customers" WHERE (`customers`.created_at >
 '2014-02-07 05:00:00.000000')


 ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR:  syntax error
 at or near "."
     LINE 1: ...LECT COUNT(*) FROM "customers"  WHERE (`customers`.created_at > '2014-02-07 05:00:00.000000')

When I convert my MYSQL database to PG then I m getting this error how can I fix this. If I right this query in MySQL then it's working fine but in PG getting error.

Help me Please...!

Thanks In Advance

1 Answer 1

2

Backticks for quoting is a MySQL-ism, standard SQL and PostgreSQL use double quotes for quoting identifiers. Somewhere you have:

where('`customers`.created_at > ?', something)

but PostgreSQL wants to see:

where('"customers".created_at > ?', something)

However, since the table name is lower case and not a reserved word, you can drop the quotes and get something that is both easier to read and will work in both databases:

where('customers.created_at > ?', something)

Presumably this change needs to be made inside the send scope.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.