> On Fri, Apr 6, 2012 at 3:08 AM, Nando <d.na
...@gmail.com> wrote:
> > That sounds very interesting. What about sql type? Is that handled
> > automagically by the Clojure JDBC library?
> Sort of. The underlying JDBC driver actually verifies / coerces the
> types to some degree but you can't pass a string ("123") where an
> integer is expected. Luckily Railo actually keeps numbers as numbers
> and dates as dates (instead of converting back and forth to strings
> like ACF does) so interop between Railo and Clojure is seamless and
> when you pass data down to the JDBC layer, it's already the right
> type. It does mean that you need to be a bit more careful about types
> in your own code, e.g., calling val() on form & URL variables that are
> supposed to be numeric and parseDateTime() or similar for dates, but
> that's just good practice anyway - and should make your code run
> faster.
> > The only way I can think to deal with sql type if the approach you
> describe
> > were implemented in CF would be some sort of hungarian notation
> Ugh! Horrible idea. Having worked with the Clojure wrapper around
> JDBC, I actually find CFML's cfqueryparam stuff to be horribly bulky
> and redundant - the driver knows what types the columns are so a
> simple parameterized SQL statement should not need any additional type
> information. Here's a typical SQL query:
> variables.orm.createIterator(
> name = "user",
> sql = "SELECT * FROM user WHERE siteId = ?
> AND username LIKE ?",
> params = [ siteId, pattern ]
> );
> That calls orm.execute( sql, params ) - which drops down thru Clojure
> to a PreparedStatement in Java - and returns a sequence of maps (think
> array of structs in CFML). The name parameter specifies what bean type
> to use (i.e,. which CFC to instantiate) and that is initialized with
> the sequence and marked as an iterator. Standard methods hasMore() and
> getNext() implement the iterator pattern. The getters return
> data[currentRow][colName]. Setter update the dirty struct. Calling
> save() performs an update based on the dirty struct.
> There is no code generation here, BTW.
> --
> Sean A Corfield -- (904) 302-SEAN
> An Architect's View -- http://corfield.org/
> World Singles, LLC. -- http://worldsingles.com/
> "Perfection is the enemy of the good."
> -- Gustave Flaubert, French realist novelist (1821-1880)
> --
> FW/1 on RIAForge: http://fw1.riaforge.org/
> FW/1 on github: http://github.com/seancorfield/fw1
> FW/1 on Google Groups: http://groups.google.com/group/framework-one
--