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
>
> > * wrapping table names in parentheses (not valid) - they can be quoted
> > using []
>
> If you are the same person that posted on IRC, this is because you did
> DB["Countries"] instead of DB[:Countries]. If you give DB#[] a
> string, it treats it as a literal SQL string, and when you did count
> on it, it uses it as a subquery (surrounding it in ()).
Yep...it takes a little while to get used to the difference in meaning
(damaged by Rail's HashWithIndifferentAccess).
>
> > * 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).
> > * when writing a date/time to the database it is trying to use an iso
> > format which doesn't work with 2000.
>
> That should be fairly easy to fix inside Dataset#literal in mssql.rb.
Yes.
> > * when writing a String to the database it is escaping \ (backslash)
> > characters even though SqlServer 2000 does not give backslash a
> > special meaning.
>
> Again, that should be fairly easy to fix inside Dataset#literal in
> mssql.rb.
Yes.
I have been looking at addressing these issues but was concerned that
I was "undoing" support for more recent versions of SQL Server. My
code so far is trivial and these breakages implied that I was using an
out-of-date backend OR the mssql code simply hasn't been used in a
while.
> I don't do any testing against MSSQL, but I do know quite a few people
> are using it. If you are one of the people that are using MSSQL with
> Sequel, please speak up and be willing to test patches.
I had started using it back in the Sequel 2.0 days - but then I got
distracted by more pressing work projects that are ActiveRecord based.
Back then things seemed to work OK - but the latest version is much
changed and as-is doesn't work with SqlServer 2000.
>
> Since you've already got patches, please submit them (pull request,
> Google code issue, pastie, etc.) so I can consider them for inclusion.
I have a fork of the project and I will look into applying my patches
if that is appropriate.
Regards,
Pete.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---