Forum: Ruby on Rails MSSQL activerecord uses bad syntax

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
39b36b2be47228f8619d61ea7a607a25?d=identicon&s=25 Matthew Beale (mixonic)
on 2006-04-07 16:57
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 Beale :: mixonic@synitech.com
Resume & Portfolio @ http://madhatted.com
6ef8cb7cd7cd58077f0b57e4fa49a969?d=identicon&s=25 Brian Hogan (Guest)
on 2006-04-07 18:39
(Received via mailing list)
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.
39b36b2be47228f8619d61ea7a607a25?d=identicon&s=25 Matthew Beale (mixonic)
on 2006-04-07 22:26
Brian Hogan 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 Beale :: mixonic@synitech.com
Resume & Portfolio @ http://madhatted.com
This topic is locked and can not be replied to.