wonderix / crystal-tds

MIT License
11 stars 2 forks source link

Fix `TDS::Connection#sp_prepare` to support `Order` token #14

Closed lachlan closed 11 months ago

lachlan commented 12 months ago

@wonderix it turns out my previous pull request to add support for ORDER BY clauses missed the list of expected tokens in TDS::Connection#sp_prepare. As a result, I was getting the following error when trying to prepare a SQL statement with an ORDER BY. This pull request fixes this issue so that SQL statements with ORDER BY clauses can be prepared without error:

Unexpected token TDS::Token::Order() while preparing "...ORDER BY 1" (DB::Error)
  from lib\tds\src\tds\connection.cr:102 in 'sp_prepare'
  from lib\tds\src\tds\connection.cr:77 in 'sp_prepare'
  from lib\tds\src\tds\prepared_statement.cr:45 in 'ensure_prepared'
  from lib\tds\src\tds\prepared_statement.cr:51 in 'perform_query'
  from lib\db\src\db\statement.cr:93 in 'perform_query_with_rescue'
  from lib\db\src\db\statement.cr:80 in 'query:args'
  from lib\db\src\db\pool_statement.cr:29 in 'query:args'
  from lib\db\src\db\query_methods.cr:46 in 'query:args'
  from lib\db\src\db\query_methods.cr:61 in 'since'
wonderix commented 11 months ago

Thank you for your contribution.