active_record_inline_schema 0.5.5 → 0.5.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ 0.5.6 / 2012-06-22
2
+
3
+ * Enhancements
4
+
5
+ * Support non-autoincrementing integer primary keys in MySQL
6
+
1
7
  0.5.5 / 2012-06-20
2
8
 
3
9
  * Enhancements
data/Gemfile CHANGED
@@ -7,11 +7,11 @@ gem 'minitest'
7
7
  gem 'minitest-reporters'
8
8
 
9
9
  platforms :ruby do
10
- # if RUBY_VERSION >= '1.9'
11
- # gem 'debugger'
12
- # else
13
- # gem 'ruby-debug19'
14
- # end
10
+ if RUBY_VERSION >= '1.9'
11
+ gem 'debugger'
12
+ else
13
+ gem 'ruby-debug19'
14
+ end
15
15
  # gem 'mysql2', '~>0.2'
16
16
  gem 'mysql2', '>=0.3'
17
17
  gem 'sqlite3'
@@ -61,9 +61,8 @@ class ActiveRecordInlineSchema::Config
61
61
  end
62
62
  elsif mysql?
63
63
  if non_standard_primary_key
64
- # only string keys are supported
65
- create_sql.sub! %r{#{connection.quote_column_name(model.primary_key)} varchar\(255\)([^,\)]*)}, "#{connection.quote_column_name(model.primary_key)} varchar(255)\\1 PRIMARY KEY"
66
- create_sql.sub! 'DEFAULT NULLPRIMARY KEY', 'PRIMARY KEY'
64
+ k = connection.quote_column_name(model.primary_key)
65
+ create_sql.sub! /#{k} *([^\)]+)(?:[^,]+),/, "#{k} \\1) PRIMARY KEY,"
67
66
  end
68
67
  connection.execute create_sql
69
68
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveRecordInlineSchema
2
- VERSION = "0.5.5"
2
+ VERSION = "0.5.6"
3
3
  end
data/spec/models.rb CHANGED
@@ -80,6 +80,13 @@ class AutomobileMakeModelYearVariant < ActiveRecord::Base
80
80
  add_index :make_model_year_name
81
81
  end
82
82
 
83
+ class Pet2 < ActiveRecord::Base
84
+ include SpecHelper
85
+ self.primary_key = "id"
86
+ col :id, :type => :integer
87
+ col :name
88
+ end
89
+
83
90
  case ENV['DB_ADAPTER']
84
91
  when 'mysql'
85
92
  class CustomMysql < ActiveRecord::Base
@@ -5,6 +5,22 @@ describe ActiveRecordInlineSchema do
5
5
  end
6
6
  end
7
7
 
8
+ it "properly registers non-incrementing integer primary keys" do
9
+ Pet2.auto_upgrade!
10
+ e = if sqlite?
11
+ ActiveRecord::StatementInvalid
12
+ else
13
+ ActiveRecord::RecordNotUnique
14
+ end
15
+ lambda do
16
+ 2.times do
17
+ p = Pet2.new
18
+ p.id = 1
19
+ p.save!
20
+ end
21
+ end.must_raise(e)
22
+ end
23
+
8
24
  it 'has #key,col,property,attribute inside model' do
9
25
  (!!ActiveRecord::Base.connection.table_exists?(Post.table_name)).must_equal false
10
26
  (!!ActiveRecord::Base.connection.table_exists?(Category.table_name)).must_equal false
data/spec/spec_helper.rb CHANGED
@@ -17,7 +17,7 @@ require 'active_record_inline_schema'
17
17
 
18
18
  require 'logger'
19
19
  ActiveRecord::Base.logger = Logger.new($stderr)
20
- ActiveRecord::Base.logger.level = Logger::DEBUG
20
+ ActiveRecord::Base.logger.level = Logger::INFO
21
21
 
22
22
  module SpecHelper
23
23
  def self.included(base)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_inline_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-06-21 00:00:00.000000000 Z
13
+ date: 2012-06-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport