0

当我将我的应用程序迁移到带有 Ruby 续集库的 Access 2007 时。我得到如下错误。有人知道如何正确迁移吗?谢谢。

C:\ContractManagement>rackup
C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/adapters/ado.rb:63:
in `method_missing': WIN32OLERuntimeError: (in OLE method `Execute': ) (Sequel::
DatabaseError)
   OLE error code:80040E14 in Microsoft Office Access Database Engine
     Syntax error (missing operator) in query expression 'LIMIT 1 1'.
   HRESULT error code:0x80020009
     Exception occurred.
       from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/adapte
rs/ado.rb:63:in `block (2 levels) in execute'
       from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/databa
se/logging.rb:28:in `log_yield'
       from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/adapte
rs/ado.rb:63:in `block in execute'
       from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/connec
tion_pool/threaded.rb:84:in `hold'
       from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/databa
se/connecting.rb:226:in `synchronize'
       from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/adapte
rs/ado.rb:61:in `execute'
       from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/datase
t/actions.rb:541:in `execute'
       from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/adapte
rs/ado.rb:97:in `fetch_rows'
       from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/datase
t/actions.rb:123:in `each'
       from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/datase
t/actions.rb:449:in `single_record'
       from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/datase
t/actions.rb:457:in `single_value'
       from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/datase
t/actions.rb:200:in `get'
       from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/datase
t/actions.rb:133:in `empty?'
       from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/extens
ions/migration.rb:499:in `schema_dataset'
       from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/extens
ions/migration.rb:381:in `initialize'
       from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/extens
ions/migration.rb:422:in `initialize'
       from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/extens
ions/migration.rb:332:in `new'
       from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/extens
ions/migration.rb:332:in `run'
       from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sequel-3.23.0/lib/sequel/extens
ions/migration.rb:316:in `apply'
       from C:/ContractManagement/config.ru:12:in `block in <main>'
       from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.3.0/lib/rack/builder.rb:
51:in `instance_eval'
       from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.3.0/lib/rack/builder.rb:
51:in `initialize'
       from C:/ContractManagement/config.ru:1:in `new'
       from C:/ContractManagement/config.ru:1:in `<main>'
       from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.3.0/lib/rack/builder.rb:
40:in `eval'
       from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.3.0/lib/rack/builder.rb:
40:in `parse_file'
       from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.3.0/lib/rack/server.rb:2
00:in `app'
       from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.3.0/lib/rack/server.rb:3
01:in `wrapped_app'
       from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.3.0/lib/rack/server.rb:2
52:in `start'
       from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.3.0/lib/rack/server.rb:1
37:in `start'
       from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.3.0/bin/rackup:4:in `<to
p (required)>'
       from C:/Ruby192/bin/rackup:19:in `load'
       from C:/Ruby192/bin/rackup:19:in `<main>'

这是连接配置。DB = Sequel.ado(:conn_string=>'Provider=Microsoft.ACE.OLEDB.12.0;数据源=C:\ContractManagement1.accdb')

这是迁移步骤。所有都在 PostgreSQL 8.4 上传递。

Sequel.migration do
  up do
    create_table :people do
      primary_key :id
      String :name, :size => 20, :unique => true, :null => false
      String :password, :size => 30, :null => false
      String :role, :size => 20, :null => false
    end
  end

  down do
    drop_table :people
  end
end

Sequel.migration do
  up do
    create_table :currencies do
      primary_key :id
      String :name, :size => 10, :null => false
    end
  end

  down do
    drop_table :currencies
  end
end

Sequel.migration do
  up do
    create_table :statuses do
      primary_key :id
      String :name, :size => 10, :null => false
    end
  end

  down do
    drop_table :statuses
  end
end

# encoding: utf-8

Sequel.migration do
  up do
    create_table :contracts do
      primary_key :id
      String :contract_id, :size => 36, :unique => true, :null => false
      String :content, :size => 150
      String :supplier, :size => 30
      Date :created_on
      Date :expired_on
      BigDecimal :amount, :size => [10, 2], :null => false
      Fixnum :debt_days
      Fixnum :guarantee_period
      String :order_id, :size => 50 # 订单号
      String :supplier_contract_id, :size => 36
      String :operator, :size => 30
      foreign_key :currency_id, :currencies, :on_delete => :cascade, :on_update => :cascade, :null => false
      foreign_key :status_id, :statuses, :on_delete => :cascade, :on_update => :cascade, :null => false
      constraint(:min_amount) { amount >= 0.01 }
    end
  end

  down do
    drop_table :contracts
  end
end

# encoding: utf-8

Sequel.migration do
  up do
    self[:currencies].insert(:name => "人民币")
    self[:currencies].insert(:name => "欧元")
    self[:currencies].insert(:name => "美元")
  end

  down do
    self[:currencies].delete
  end
end

# encoding: utf-8

Sequel.migration do
  up do
    self[:statuses].insert(:name => "执行中")
    self[:statuses].insert(:name => "关闭")
    self[:statuses].insert(:name => "作废")
  end

  down do
    self[:statuses].delete
  end
end

# encoding: utf-8

Sequel.migration do
  up do
    create_table :payments do
      primary_key :id
      BigDecimal :prepayment, :size => [10, 2], :default => 0 # 预付金额(元)
      BigDecimal :offset_prepayment, :size => [10, 2], :default => 0 # 冲预付
      BigDecimal :guarantee_price, :size => [10, 2], :default => 0 # 质保金
      BigDecimal :request_amount, :size => [10, 2], :default => 0 # 申请付款额
      foreign_key :contract_id, :contracts, :on_delete => :cascade, :on_update => :cascade
      foreign_key :person_id, :people, :on_delete => :cascade, :on_update => :cascade
      constraint(:offset_prepayment_is_not_greater_than_prepayment) { prepayment >= offset_prepayment } # offset_prepayment不能大于prepayment
    end
  end

  down do
    drop_table :payments
  end
end

Sequel.migration do
  up do
    {"admin" => "Admin", "contract" => "ContractOperator", "payment" => "PaymentOperator", "report" => "ReportReviewer"}.each do |n, r|
      self[:people].insert(:name => n, :password => n, :role => r)
    end
    self[:people].insert(:name => "payment1", :password => "payment1", :role => "PaymentOperator")
  end

  down do
    self[:people].delete
  end
end
4

2 回答 2

1

我认为您收到此错误消息...

OLE error code:80040E14 in Microsoft Office Access Database Engine
     Syntax error (missing operator) in query expression 'LIMIT 1 1'.

...因为 Access SQL 不支持 LIMIT。请参阅对相关 Stack Overflow 问题的回复。

查看是否可以使用 Access SQL TOP N 代替 LIMIT N。

SELECT TOP 1 m.id, m.paid_in_full, m.date_field
FROM MyTable AS m
ORDER BY m.date_field DESC;
于 2011-05-25T19:53:56.270 回答
0

这是在 Sequel 的 master 分支中修复的,版本 3.24.0(将在下周发布)将进行错误修复。

于 2011-05-25T23:07:24.487 回答