Re: [gnome-db] gda_connection_statement_to_sql() without a connection





On 9 November 2011 13:36, Murray Cumming <murrayc murrayc com> wrote:
On Wed, 2011-11-09 at 13:27 +0100, Vivien Malerba wrote:
>
>
> On 9 November 2011 11:06, Murray Cumming <murrayc murrayc com> wrote:
>         In libglom, I'm using
>         gda_connection_statement_to_sql()
>         http://developer.gnome.org/libgda/unstable/GdaConnection.html#gda-connection-statement-to-sql
>         to generate a SQL statement that's appropriate for the
>         particular
>         backend (PostgreSQL mostly), with the correct quoting (because
>         I use
>         GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE when
>         opening the
>         connection).
>
>         However, I don't always want an actual connection, because
>         OnlineGlom
>         then uses that SQL string with its own JDBC Java API.
>
>         So is there any easy way to get that SQL string without
>         actually
>         connecting to the server? gda_statement_to_sql() seems to
>         ignore the
>         connection and the quoting for case-sensitivity.
>         http://developer.gnome.org/libgda/unstable/GdaStatement.html#gda-statement-to-sql
>
> There is no easy way of doing this. After a quick analysis, the best
> to implement this feature (easiest to use and clean solution) would be
> to allow one to create GdaConnection objects but with the connection
> closed (which is in fact very easy to do). You could then use the
> gda_connection_statement_to_sql() normally, and then either discard
> the connection, or call gda_connection_open() if you need to execute
> statements. Would it suit your needs?

I guess that would work. It would solve my problem.

It's now in commit http://git.gnome.org/browse/libgda/commit/?id=722edc0ce116466e2193304b539a632d6478f6ce
 

I was thinking that I should somehow call the appropriate code in the
provider without using a connection.

I thought too, but the GdaConnection object is used as well in the process, hence the better solution of connections created closed.

Regards,

Vivien


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]