When I try to execute the following code, the correct SQL statement is prepared, but I get an error that I need to explicitly cast my data type for the parameter. This doesn''t seem right; the parameter should be an integer, and I tried hard-coding in an explicit integer and got the same message. I am using PostgreSQL The field "user_id" is type int4. Does anyone know what might be happening here? Here is the code: user = Patient.find(@params[:pid]) group = Group.find(@params[:group][:id]) existing_group_member = group.group_members.find (:first, :conditions => ["user_id=?", user.id]) And here is the error message on the web page: ERROR C42883 Moperator does not exist: integer =? integer HNo operator matches the given name and argument type(s). You may need to add explicit type casts. Fparse_oper.c L788 Rop_error: SELECT * FROM group_members WHERE group_members.group_id = 2 AND user_id=?15 LIMIT 1 Request Parameters: {"pid"=>"15", "submit"=>"Add", "group"=> {"id"=>"2"}} thanks, Jeff
On 6/28/05, Jeff Cole <cole.jeff-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> When I try to execute the following code, the correct SQL statement > is prepared, but I get an error that I need to explicitly cast my > data type for the parameter. This doesn''t seem right; the parameter > should be an integer, and I tried hard-coding in an explicit integer > and got the same message. > > I am using PostgreSQL The field "user_id" is type int4. Does > anyone know what might be happening here? > > Here is the code: > user = Patient.find(@params[:pid]) > group = Group.find(@params[:group][:id]) > existing_group_member = group.group_members.find > (:first, :conditions => ["user_id=?", user.id]) >existing_group_member = group.group_members.find (:first, :conditions => ["user_id =", user.id])> And here is the error message on the web page: > ERROR C42883 Moperator does not exist: integer =? integer > HNo operator matches the given name and argument type(s). You may > need to add explicit type casts. Fparse_oper.c L788 > Rop_error: SELECT * FROM group_members WHERE group_members.group_id > 2 AND user_id=?15 LIMIT 1 > Request Parameters: {"pid"=>"15", "submit"=>"Add", "group"=> > {"id"=>"2"}} > > thanks, > Jeff > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Sorry, a little quick to hit the send button on my first reply. On 6/28/05, Jeff Cole <cole.jeff-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> When I try to execute the following code, the correct SQL statement > is prepared, but I get an error that I need to explicitly cast my > data type for the parameter. This doesn''t seem right; the parameter > should be an integer, and I tried hard-coding in an explicit integer > and got the same message. >The correct sql is not prepared. Look closely.> I am using PostgreSQL The field "user_id" is type int4. Does > anyone know what might be happening here? > > Here is the code: > user = Patient.find(@params[:pid]) > group = Group.find(@params[:group][:id]) > existing_group_member = group.group_members.find > (:first, :conditions => ["user_id=?", user.id]) > > And here is the error message on the web page: > ERROR C42883 Moperator does not exist: integer =? integer > HNo operator matches the given name and argument type(s). You may > need to add explicit type casts. Fparse_oper.c L788 > Rop_error: SELECT * FROM group_members WHERE group_members.group_id > 2 AND user_id=?15 LIMIT 1"user_id=?15" is what is giving the error. This is a bug in rails. http://dev.rubyonrails.com/ticket/1281> Request Parameters: {"pid"=>"15", "submit"=>"Add", "group"=> > {"id"=>"2"}} > > thanks, > Jeff > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >