默认情况下,续集模型不会映射所有列。
我正在使用: 续集版本4.24.0 Ruby版本1.9.3p194 Windows Server 2008 Enterprise SQLServer 2008 R2企业版
下面是一个显示问题的简短脚本:
require "sequel"
DB = Sequel.ado(:conn_string=>CONNECTION_STRING)
print "Loading LnProfile... "
class LnProfile < Sequel::Model(:lnprofile)
# attr_accessor :crawl_start_time
end
puts "Done!"
id = "808d8421-6c05-471e-addc-6165de044ad3"
# crawl_start_time field shouldn't be empty
p1 = LnProfile.where(:id=>id).first
puts ".id:#{p1.id.to_s}:." # => .id:808d8421-6c05-471e-addc-6165de044ad3:.
puts ".crawl_start_time:#{p1.crawl_start_time.to_s}:." # => .crawl_start_time::.
# same record, different data
p2 = LnProfile.select_all.select_append(:crawl_start_time).where(:id=>id).first
puts ".id:#{p2.id.to_s}:." # => .id:808d8421-6c05-471e-addc-6165de044ad3:.
puts ".crawl_start_time:#{p2.crawl_start_time.to_s}:." # => .crawl_start_time:2016-01-10 12:02:29 -0300:.
以下是上述脚本的输出:
Loading LnProfile... Done!
.id:{808D8421-6C05-471E-ADDC-6165DE044AD3}:.
.crawl_start_time::.
.id:{808D8421-6C05-471E-ADDC-6165DE044AD3}:.
.crawl_start_time:2016-01-10 12:02:29 -0300:.
请指教。当代码加载一个对象并再次将其保存几行时,这个问题就会弄乱数据库。
提前致谢。
答案 0 :(得分:0)
尝试使用tinytds适配器,它比ado适配器更强大。