datamapper / dm-do-adapter Goto Github PK
View Code? Open in Web Editor NEWA Data Objects Adapter for DataMapper
Home Page: http://datamapper.org/
License: MIT License
A Data Objects Adapter for DataMapper
Home Page: http://datamapper.org/
License: MIT License
The dm-do-adapter repository does not have a Gemfile.
Hello, I discovered a bug when retrieving records with a Time property saved with a certain value.
Versions:
ruby-2.2.1
data_mapper (1.2.0)
data_objects (0.10.16)
dm-aggregates (1.2.0)
dm-constraints (1.2.0)
dm-core (1.2.1)
dm-do-adapter (1.2.0)
dm-migrations (1.2.0)
dm-serializer (1.2.2)
dm-sqlite-adapter (1.2.0)
dm-timestamps (1.2.0)
dm-transactions (1.2.0)
dm-types (1.2.2)
dm-validations (1.2.0)
do_sqlite3 (0.10.16)
To reproduce:
require 'time'
require 'data_mapper'
DataMapper.setup(:default, 'sqlite::memory:')
class Song
include DataMapper::Resource
property :id, Serial
property :time, Time, :required => true
end
DataMapper.finalize
DataMapper.auto_upgrade!
t = Time.parse("2016-01-01 00:00:00.00005000 -05:00")
Song.create(time: t)
Song.at(0) # works
t = Time.parse("2016-01-01 00:00:00.00000000 -05:00") # no problems with this object
Song.create(time: t) # saves with no problems
Song.at(1) # # will raise error here
Error returned:
/home/rob/.rvm/gems/ruby-2.2.1/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:153:in `local': argument out of range (ArgumentError)
from /home/rob/.rvm/gems/ruby-2.2.1/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:153:in `next!'
from /home/rob/.rvm/gems/ruby-2.2.1/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:153:in `block in read'
from /home/rob/.rvm/gems/ruby-2.2.1/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:276:in `with_connection'
from /home/rob/.rvm/gems/ruby-2.2.1/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:141:in `read'
from /home/rob/.rvm/gems/ruby-2.2.1/gems/dm-core-1.2.1/lib/dm-core/repository.rb:162:in `read'
from /home/rob/.rvm/gems/ruby-2.2.1/gems/dm-core-1.2.1/lib/dm-core/model.rb:378:in `first'
from main.rb:18:in `<main>'
Note: changing column to DateTime later, allows me to access the values
property :time, DateTime, :required => true
On models with Binary
properties, which #dump
the data with force_encoding("BINARY")
, the DataObjects adapter doesn't pay attention to the encoding and builds a "UTF-8" encoded string containing non-UTF-8 data. This manifests in an explosion when using the New Relic middleware, which introspects queries.
the error is something about a badly formatted url
Malformed URI: java.net.URISyntaxException: Expected scheme-specific part at index 7: sqlite:
from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/data_objects-0.10.2/lib/data_objects/connection.rb:76:in `new'
from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/data_objects-0.10.2/lib/data_objects/pooling.rb:177:in `new'
from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/data_objects-0.10.2/lib/data_objects/pooling.rb:172:in `new'
from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/data_objects-0.10.2/lib/data_objects/pooling.rb:119:in `new'
from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/data_objects-0.10.2/lib/data_objects/connection.rb:65:in `new'
from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/dm-do-adapter-1.0.2/lib/dm-do-adapter/adapter.rb:235:in `open_connection'
from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/dm-transactions-1.0.2/lib/dm-transactions/adapters/dm-do-adapter.rb:65:in `open_connection'
from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/dm-do-adapter-1.0.2/lib/dm-do-adapter/adapter.rb:260:in `with_connection'
from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/dm-do-adapter-1.0.2/lib/dm-do-adapter/adapter.rb:138:in `read'
from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/dm-core-1.0.2/lib/dm-core/repository.rb:162:in `read'
from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/dm-core-1.0.2/lib/dm-core/model.rb:379:in `first'
from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/dm-core-1.0.2/lib/dm-core/model.rb:446:in `first_or_create'
from /Users/path/Projects/pg/pgservice/app/handlers/create_user_handler.rb:9:in ... (user code)
Created by pathsny (at gmail) - 2010-09-09 17:38:26 UTC
Original Lighthouse ticket: http://datamapper.lighthouseapp.com/projects/20609/tickets/1400
As of data_objects 0.10.5 I have begun getting the following warning in my datamapper project
DataObjects::URI.new with arguments is deprecated, use a Hash of URI components (.../gems/dm-do-adapter-1.1.0/lib/dm-do-adapter/adapter.rb:231:in `new')
See this thread:
http://groups.google.com/group/datamapper/browse_thread/thread/47c04728de93b2ee
If I have 2 models (Sentence, Word), which have a Many-to-Many
relationship, and Word has a field 'word', the following query:
Sentence.all(:words => { :word => "Hello" })
Tries to match "sentences.id" to "words.id" (live example at
http://pastebin.ca/2097242 ) :
FROM "sentences"
WHERE "id" IN
(SELECT "words"."id" # Query result will be a single words.id,
which will be used as sentence id
FROM "words"
INNER JOIN "sentence_words" ON "words"."id" =
"sentence_words"."word_id"
INNER JOIN "sentences" ON "sentence_words"."sentence_id" =
"sentences"."id"
WHERE "words"."word" = 'Hello')
ORDER BY "id"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.