datamapper / dm-mysql-adapter Goto Github PK
View Code? Open in Web Editor NEWA mysql Adapter for DataMapper
Home Page: http://datamapper.org/
License: MIT License
A mysql Adapter for DataMapper
Home Page: http://datamapper.org/
License: MIT License
I'm filing this here because I'm assuming that it's a bug with the adapter, but I'm not entirely sure. It works with sqlite3, but that may just be a coincidence.
Anyhow, I made a repo, https://github.com/jdodds/datamapper-bug , that demonstrates the behavior. I have a model with a composite primary key, and two models that refer to it with belongs_to ..., :key => true
, while it has the corresponding has n
declarations. Looking at the logs, it creates the first model's table correctly, but either fails to detect or ignores the composite key when creating the second model's table.
If you need any more info, let me know.
sample code derived from http://datamapper.org/docs/create_and_destroy.html,
When you run it the second time you'll get the error:
/pr/tasks/ruby/datamapper/dm/dm-core/lib/dm-core/property.rb:712:in `assert_valid_value': Invalid value nil for property :body (DataMapper::Property::Text) on model Post (DataMapper::Property::InvalidValueError)
CODE:
# encoding: UTF-8
require 'dm-core'
$DATA_MAPPER_MYSQL_CONNECTION = 'mysql://root:mysqlpage@localhost/datamapper'
# If you want the logs displayed you have to do this before the call to setup
DataMapper::Logger.new($stdout, :debug)
DataMapper.setup(:default, $DATA_MAPPER_MYSQL_CONNECTION )
# by default all fields are required
DataMapper::Property.required(true)
DataMapper::Property::String.length(120)
DataMapper::Property::Boolean.allow_nil(false)
DataMapper::Model.raise_on_save_failure = true
class Post
include DataMapper::Resource
property :id, Serial
property :title, String
property :body, Text
end
DataMapper.finalize
require 'dm-migrations'
DataMapper.auto_upgrade!
if Post.first
puts "phase2 editing post"
post = Post.first
post.title = "dummy"
# this causes an exception because body porperty is nil because its loaded lazily !?
post.save
else
puts "creating post, rerun script!"
post = Post.create({
:title => "My first DataMapper post",
:body => "A lot of text ...",
})
end
# repository(:default).adapter.execute('COMMIT')
This causes the feeling that the mysql backend (and maybe all?) are still kind of unstable.
Tell me if I should file this bug against a different github repo.. maybe its not related to mysql at all.
gem install dm-mysql-adapter
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing dm-mysql-adapter:
ERROR: Failed to build gem native extension.
current directory: C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/do_mysql-0.10.17/ext/do_mysql
C:/Ruby22-x64/bin/ruby.exe -r ./siteconf20161223-7120-yyjae.rb extconf.rb
checking for my_global.h... no
checking for mysql.h... no
checking for main() in -llibmysql... no
checking for mysql_query() in mysql.h... no
checking for mysql_ssl_set() in mysql.h... no
checking for localtime_r()... yes
checking for gmtime_r()... yes
checking for mysql.h... no
checking for MYSQL_TYPE_STRING in mysql.h... no
checking for MYSQL_TYPE_BIT in mysql.h... no
checking for MYSQL_TYPE_NEWDECIMAL in mysql.h... no
checking for mysql_query() in mysql.h... no
checking for mysql_ssl_set() in mysql.h... no
checking for mysql_sqlstate() in mysql.h... no
checking for mysql_get_ssl_cipher() in mysql.h... no
checking for mysql_set_character_set() in mysql.h... no
checking for mysql_get_server_version() in mysql.h... no
checking for mysql_real_escape_string_quote() in mysql.h... no
checking for MYSQL_FIELD.charsetnr in mysql.h... no
checking for rb_thread_fd_select()... yes
creating Makefile
To see why this extension failed to compile, please check the mkmf.log which can be found here:
C:/Ruby22-x64/lib/ruby/gems/2.2.0/extensions/x64-mingw32/2.2.0/do_mysql-0.10.17/mkmf.log
current directory: C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/do_mysql-0.10.17/ext/do_mysql
make "DESTDIR=" clean
current directory: C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/do_mysql-0.10.17/ext/do_mysql
make "DESTDIR="
generating do_mysql-x64-mingw32.def
compiling do_common.c
compiling do_mysql.c
do_mysql.c:8:19: fatal error: mysql.h: No such file or directory
compilation terminated.
make: *** [do_mysql.o] Error 1
make failed, exit code 2
Gem files will remain installed in C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/do_mysql-0.10.17 for inspection.
Results logged to C:/Ruby22-x64/lib/ruby/gems/2.2.0/extensions/x64-mingw32/2.2.0/do_mysql-0.10.17/gem_make.out
I'm trying to connect to a mysql 5.6 database and get this error: client secure_auth enabled. I tried to set OLD_PASSWORD('password') to the user, but it didn't work. Also tried with no success to set :secure_auth => false in the setup options.
Did anyone face this problem? Am I missing something?
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.