On Dec 17, 3:11 pm, Pete <[email protected]> wrote:
> On Dec 17, 2:56 am, Jeremy Evans <[email protected]> wrote:> On Dec 16,
> 4:59 am, Pete <[email protected]> wrote:
>
> (edited for the sake of brevity)
>
> > > The issues I have been encountering are:
> > > * attempting to quote column names with " (not valid) rather than
> > > surrounding them in []
>
> > This is fairly simple to fix by adding a quoted_identifier method that
> > uses [] instead of "" to quote identifiers. The MSSQL adapter already
> > does this, so make sure you are using :db_type=>'mssql' option when
> > instantiating the database.
>
> I'm sorry, but in the version of Sequel that I installed (2.8.0) this
> doesn't appear to be the case:
> (from mssql.rb):
> def literal(v)
> case v
> when String
> "N#{super}"
> when Time
> literal(v.iso8601)
> when Date, DateTime
> literal(v.to_s)
> else
> super
> end
> end
That's the literal method, not the quoted_identifier method:
80 def quoted_identifier(name)
81 "[#{name}]"
82 end
If you are using MSSQL, identifiers should be quoted with []. If
that's not the case, I'm not sure where the bug is and could use help
in tracking it down.
> > > * when calling dataset.count it generates something like "select NCOUNT
> > > (*) from table" which isn't valid
>
> > I'm not sure where the NCOUNT is coming from, it doesn't appear to be
> > Sequel (according to fgrep -ri ncount). If Sequel is using NCOUNT
> > someplace, please let me know.
>
> It comes from the way that literal is implemented in the mssql/odbc
> classes. "COUNT(*)" is a LiteralString which is converted to a String
> and piped through #literal(v) again. From the above snippet I pasted
> you can see that mssql puts N in front of it (the idea here is that
> any quoted string literal is considered Unicode if it has the N in
> front of it).
That was a bug in MSSQL's literal method, thanks for bringing it to my
attention. I just fixed it:
http://github.com/jeremyevans/sequel/commit/17d5c6a56ae554d69d424dc0cb11185cef480843
> I have a fork of the project and I will look into applying my patches
> if that is appropriate.
Please do, and send me pull requests. I generally cherry-pick
patches, so having a separate commit for each feature/bugfix makes it
easier. Also, if anyone else here uses MSSQL 2005 and can verify that
nothing breaks with the patches, that would be a big help.
Jeremy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---