DataMapper Logging and Eager Loading

6 views
Skip to first unread message

cjmeyer

unread,
May 20, 2008, 10:49:42 PM5/20/08
to DataMapper
When I use DataMapper with my Merb project, it creates a log file log/
dm.log and I see nothing but...

Tue, 20 May 2008 02:40:01 GMT ~ info ~ Logfile created

Is this the expected behaviour? How can I get more logging information
like the actual SQL statements being issued. I see some being issued
to STDOU if I run with "merb -i" but I want to log the SQL statements
as I run in non-interactive mode.

Also, I can't seem to eager load associations. I have pastie'd some
demo code at http://pastie.caboo.se/200642. This seems to geneate
multiple SQL statements instead of eager loading (when loading a
single Article I am attempting to eager load the associated comments,
the article body, and the associated comments bodies).

I am not sure if I am doing it right and I am still VERY new to both
Merb and DataMapper so it could be something very simple that I am
missing for both issues.

Sam Smoot

unread,
May 21, 2008, 2:29:28 AM5/21/08
to DataMapper
We'll look into these. Would you mind creating tickets in the tracker
for them though so they don't get lost? I believe there's a ticket for
the logging issue already.

On May 20, 9:49 pm, cjmeyer <cjme...@gmail.com> wrote:
> When I use DataMapper with my Merb project, it creates a log file log/
> dm.log and I see nothing but...
>
> Tue, 20 May 2008 02:40:01 GMT ~ info ~ Logfile created
>
> Is this the expected behaviour? How can I get more logging information
> like the actual SQL statements being issued.  I see some being issued
> to STDOU if I run with "merb -i" but I want to log the SQL  statements
> as I run in non-interactive mode.
>
> Also, I can't seem to eager load associations.  I have pastie'd some
> demo code athttp://pastie.caboo.se/200642. This seems to geneate

Corrin Meyer

unread,
May 21, 2008, 8:20:42 AM5/21/08
to datam...@googlegroups.com
I have added them to the bug tracker.

Khang Toh

unread,
May 22, 2008, 3:16:24 PM5/22/08
to DataMapper
Sorry if I did this does not make sense, I'm still a newbie to DM.
Anyway, I took some time to find out what's going on and looks like
the DataObjects loggers are not being instantiated.

I tried doing this in merb -i <<
DataObjects::Mysql.logger = DataObjects::Logger.new('log/dm.log', 0)
and I was then able to the query logging.

Then I wanted to work on a patch but wasn't sure but to start.
Basically I think DO loggers should be instantiated in the each of the
respective adapters. Correct?

There's an open bug for this here for anyone interested:
http://wm.lighthouseapp.com/projects/4819/tickets/297-datamapper-not-logging-sql-queries#ticket-297-3

Khang

On May 20, 10:49 pm, cjmeyer <cjme...@gmail.com> wrote:
> When I use DataMapper with my Merb project, it creates a log file log/
> dm.log and I see nothing but...
>
> Tue, 20 May 2008 02:40:01 GMT ~ info ~ Logfile created
>
> Is this the expected behaviour? How can I get more logging information
> like the actual SQL statements being issued. I see some being issued
> to STDOU if I run with "merb -i" but I want to log the SQL statements
> as I run in non-interactive mode.
>
> Also, I can't seem to eager load associations. I have pastie'd some
> demo code athttp://pastie.caboo.se/200642. This seems to geneate
Reply all
Reply to author
Forward
0 new messages