ActiveRecord::Base.logger is passed into your connection adapter at the
time of instantiation. If you change your class “logger” object, it is
not reflected in the adapter. This is a bug in rails IMO.
For a temporary workaround you can use:
ModelClass.connection.instance_eval( “@logger=Logger.new( STDOUT )” )
I will submit ticket and patch tomorrow.
Zach
Does this mean if I write
ActiveRecord::Base.logger = …
before I define my class:
class Document < ActiveRecord::Base
…
That it should work also?
At any rate, trying that, and what you suggested doesn’t give me
anything.
Maybe I’m mis-understanding it:
Based on random googles, but it doesn’t seem to give me anything.
Is there a different list I could perhaps put this question too?
ActiveRecord::Base.logger is passed into your connection adapter at the
time of instantiation. If you change your class “logger” object, it is
not reflected in the adapter. This is a bug in rails IMO.
For a temporary workaround you can use:
ModelClass.connection.instance_eval( “@logger=Logger.new( STDOUT )” )
I will submit ticket and patch tomorrow.
Zach
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
First of all, thanks for your help, I’ve been trying to figure this out
for about a week with little success. Seems like it (AR) could be a
really nice abstraction, I just haven’t got it working quite right
yet…
zdennis wrote:
ActiveRecord::VERSION::STRING
=> “1.14.4”
What version of ActiveRecord are you using?
Zach
For me,
ActiveRecord::VERSION::STRING
=> “1.14.4”
FWIW, i’m using ruby 1.8.4, on cygwin.
I installed AR using rubygems, then installed OpenLink’s ODBC connection
adapter (is it the adapter’s job to send the SQL to the logger?) and
finally monkey-patched it a bit, in a similar fashion to dbi’s ODBC
class, to allow it to use odbc_utf8, and to allow the use of simple dsns
in string form.
I connect using:
ActiveRecord::Base.establish_connection :adapter => ‘odbc’,
:dsn => ‘driver=Microsoft Access Driver (*.mdb); dbq=’ +
mdb_filename
(All this is in aid of writing a script that works on someone else’s
Access database.)
FWIW, i’m using ruby 1.8.4, on cygwin.
I installed AR using rubygems, then installed OpenLink’s ODBC connection
adapter (is it the adapter’s job to send the SQL to the logger?)
Yes it is the adapters responsbility to log the SQL. This usually
occurs in an ‘execute’ method on the implemented adapter.
Can you send me your adapter code ?
Zach
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
I saw your Dec. 2006 post that mentioned connecting via ‘ODBC’ to a
Microsoft Access db. I know it was a while ago but I am new to Rails
and would like to connect to a legacy systems Access db and could use
some help. I have installed the adapters but I am unsure of what
other things need to be done. Does the “establish_connection” go in a
model named for the Access db? What if anything goes in the database
yml?
Thanks.
Lewis
On Dec 18 2006, 6:41 pm, Charles L. <rails-mailing-l…@andreas-
Yes it is the adapters responsbility to log the SQL. This usually
occurs in an ‘execute’ method on the implemented adapter.
Can you send me your adapter code ?
Zach
Ahh, so that’d be the problem then. I see the SQLite adapter is doing
some definite logging:
sqlite:
def execute(sql, name = nil) #:nodoc:
catch_schema_changes { log(sql, name) { @connection.execute(sql) } }
end
odbc:
def execute(sql, name = nil) @logger.unknown(“ODBCAdapter#execute>”) if @@trace @logger.unknown(“args=[#{sql}|#{name}]”) if @@trace
if sql =~ /^\s*INSERT/i && [:microsoftsqlserver,
:virtuoso].include?(@dbmsName)
# Guard against IDENTITY insert problems caused by explicit inserts
# into autoincrementing id column.
insert(sql, name)
else
begin @connection.do(sql)
rescue Exception => e @logger.unknown(“exception=#{e}”) if @@trace
raise StatementInvalid, e.message
end
end
end
Further more, while the sqlite functions such as #select_all, go through
execute, the odbc version doesn’t.
I suppose I can set @@trace variable…
Is there an official odbc connector?
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.