Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
SQLite/ActiveRecord and Backslashes
David Naseby
10/5/2004 12:34:00 PM
I've got a problem with some combination of SQLite, ActiveRecord, and my
brain. Backslashed strings don't load properly from ActiveRecord, as shown
by the following script:
require 'rubygems'
require 'sqlite'
require_gem 'activerecord'
require 'test/unit'
File.delete( "test.db" ) if File.exist?( "test.db" )
db = SQLite::Database.new( "test.db", 0644 )
db.execute <<EOE
CREATE TABLE samples (
id INTEGER PRIMARY KEY,
name VARCHAR( 255 )
)
EOE
db.close
class Sample < ActiveRecord::Base; end
ActiveRecord::Base.establish_connection(
:adapter => "sqlite",
:dbfile => "test.db"
)
class TC_ActiveRecordSqliteError < Test::Unit::TestCase
def test_backslash
sample = Sample.new 'name' => '\\'
assert sample.save
assert_equal '\\', sample.name ## this works
sample_copy = Sample.find sample.id
assert_equal '\\', sample_copy.name ## this fails
end
end
This produces:
1) Failure:
test_backslash(TC_ActiveRecordSqliteError)
[C:/Clients/newlite/spike/error.rb:30]:
<"\\"> expected but was
<"\\\\">.
Anyone have any idea whats wrong, or how to fix it?
David
http://homepages.ihug.com.a...
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
SQLite/ActiveRecord and Backslashes
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password