Hi there

First up, thanks for all the hard work on a great database library and
abstraction layer. We're really going to enjoy using it on our new
JRuby / SQLServer application.

Our database admin guys often run profiling jobs on the database which
would throw up a list of SQL statements that run long repeatedly. They
come to us and we would often have a tough time working out where in
code the SQL statement resides because of the Sequel abstraction
layer. This of course is not unique to Sequel.

For hand written SQL we sometimes provide a comment to link it back to
the code, so:

/* Clients query */ SELECT * FROM CLIENTS

We can then search our code base for the string /* Clients query */ in
order to quickly find the correct line.

So I was going to propose a way to 'tag' a Sequel statement with an
identifier that gets built into the string executed:

@results =  settings.databases[:my_database][:clients]
    .join(:clientsettings, :clientid => :clientid)
    .where(:firstname.like('Ciaran%'))
    .select(:clients__clientid, :firstname, :isinternalaccount, :status)
    .tag('clients query')
    .all

Which would execute:

/* clients query */ SELECT [CLIENTS].[CLIENTID], [FIRSTNAME],
[ISINTERNALACCOUNT], [STATUS] FROM [CLIENTS] INNER JOIN
[CLIENTSETTINGS] ON ([CLIENTSETTINGS].[CLIENTID] = [CLIENTS].
[CLIENTID]
) WHERE (([FIRSTNAME] COLLATE Latin1_General_CS_AS) LIKE (N'Ciaran%'
COLLATE Latin1_General_CS_AS))


If there is another way to do this, or a fundamental reason why this
is a bad idea, please let me know.

Cheers,
Ciaran

Cheers,
Cairan

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

Reply via email to