MSSQL activerecord uses bad syntax

Hi all,

I’m trying to get rails up on mssql for a friend, does anyone have
experience? We’re working on a Windows XP box with MSSQL 2000 (no
service pak), and both rails (1.1) and MSSQL are on the same box. I’m
running into a bug (I think) where activerecord is using this syntax:

SELECT TOP 1 * FROM users WHERE (users.user = ‘jbgnuumnbu’)

However, users.user is not a valid syntax in MSSQL. Why doesn’t AR
handle this? Arn’t other people using this without problems?

Found the error running rake migrate.


Matthew B. :: [email protected]
Resume & Portfolio @ http://madhatted.com

Looks correct to me.
users is the table, and user is the column. tablename.columnname is
always
acceptable because of possible ambiguity.

@user = User.find_by_username(‘jbgnuumnbu’) would return exactly what
you
see there.

Brian H. wrote:

Looks correct to me.
users is the table, and user is the column. tablename.columnname is
always
acceptable because of possible ambiguity.

Well it may work in find_by, yeah. The error was from the
validates_as_unique, so I’ve gone and changed it to not use the table
name. I’m not sure if the rest of rails uses it as well. Another
frustrating point has arisen though.

The rake tests uses a DBI string for the “host” argument of the mssql db
dump/import tool (called scrtxfr or something). The host argument
actually needs to be just the host. If I change the host in
database.yml, I make rails no longer connect to mssql via AR.

Is anyone out there using mssql?


Matthew B. :: [email protected]
Resume & Portfolio @ http://madhatted.com