Hi Ivan,

> Um; I'd rather an adapter method that's something more like:
>
> to_native_query(query) => SQL for RDBMS, but allows other query languages
> too.

Yeah, although not all adapters use a string based query language.
Some use other lower level libraries where you construct your query
through method calls. A web service may require a special URL and
possibly a POST message body to perform a query. I'm not sure it could
be generalized in a way that makes sense across the board.

What I'm leaning towards is extracting the SQL generation code in the
adapter into a separate class, and then having it so that you can use
it stand-alone, or you can access it through an adapter. I'm guessing
the API would be something like this:

  # connection is the DataObjects driver connection
  # query is the DataMapper::Query instance

  generator =
DataMapper::Adapters::DataObjectsAdapter::SQLGenerator.new(connection,
query)
  generator.to_s  # => the SQL query

Or via the adapter, eg:

  generator = repository(:default).adapter.sql_generator(query)
  generator.to_s  # => the SQL query

The reason we need the connection is that the SQL query is quoted
using the connection's native C/Java quoting methods.

People are welcome to introduce helper methods that cut things down
further if they wish.

--

Dan
(dkubb)

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
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/datamapper?hl=en.

Reply via email to