>
> Model.plugin :prepared_statements
> Model[m1.id]
>
> or:
>
> Model.filter(:id=>:$id).prepare(:first, :m1).call(:id=>m1.id)
>
> With either of these methods, it should use a placeholder, and pass the
> variable as a prepared statement argument. Unfortunately, I'm not sure
> that will work on mysql, because on mysql prepared statement arguments are
> still sent in a query.
>
Actually, this works. I get this from the SQL:
Model.plugin :prepared_statements
Model[m1.id]
Model.filter(:id=>:$id).prepare(:first, :m1).call(:id=>m1.id) => #<Network
@values={:id=>"\u0016\u00EF|T\u00C1a\u0011\u00E1\u008BD\u0003+\u00CC\u0081
\u001C"}>
PREPARE m1: SELECT * FROM `models` WHERE (`id` = ?) LIMIT 1
EXECUTE n1; ["\u0016\u00EF|T\u00C1a\u0011\u00E1\u008BD\u0003+\u00CC\u0081
\u001C"]
> class Model
> plugin :typecast_on_load, :id
> def id=(v)
> v.is_a?(String) ? super(UUIDTools::UUID.parse_raw(v) : super
> end
> end
> class UUID
> def sql_literal(ds)
> "uuid2binary(#{ds.literal(to_s)})"
> end
> end
>
Depending on how this evolves, this might be the solution.
> I don't suppose you'd be amenable to checking if it works on ruby 1.8?
>
Does running JRuby in 1.8 mode count? I got similar results except:
m1 => #<Model @values={:id=>"\026\357|T\301a\021\341\213D\003+\314\201
\034"}>
If you want me to use real 1.8, let me know. I have to actually install it
and get the project set up to work in it which will take a bit of time.
(Can't use JDBC, etc.) With that sai, could this be JDBC specific? I can
run this in MRI 1.8 or 1.9 and hit it with the C driver if you would like.
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/sequel-talk/-/dcCmolJesPQJ.
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.