balderdashy / waterline-docs

WARNING: The content in this repo is out of date! See https://github.com/balderdashy/sails-docs for the most up-to-date documentation
452 stars 161 forks source link

query method mis-documented #97

Open devinivy opened 9 years ago

devinivy commented 9 years ago

At https://github.com/balderdashy/waterline-docs/blob/master/queries/query-methods.md#query-query-data-callback- the format of the query is shown as,

Movie.query('SELECT * FROM movie WHERE title = $1', [title] //...

but it should use ? instead, as such,

Movie.query('SELECT * FROM movie WHERE title = ?', [title] //...

Related: https://github.com/balderdashy/sails-mysql/issues/245

particlebanana commented 9 years ago

@devinivy wouldn't this depend on the adapter you are using? Postgresql accepts $1 just fine.

devinivy commented 9 years ago

Ah, yeah it probably does. That method just uses the driver's query method directly. The mysql driver wants ?s. As long as they're consistent, I don't think there's any problem, but it sounds like there's an update needed. Maybe both adapters could support both syntaxes for now?

particlebanana commented 9 years ago

We don't do any parsing of the strings sent to the .query method. The actual drivers are different so one accepts $1 and one accepts ?. We would have to parse the query string to make it support both. We can just change the example or put one example with a postgresql label and one with a mysql label sort of how Knex shows examples for different databases.