sequel 0.1.9.4 → 0.1.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG CHANGED
@@ -1,3 +1,13 @@
1
+ === SVN
2
+
3
+ * Added :elements option to column definition, in order to support ENUM and SET types.
4
+
5
+ === 0.1.9.5 (2007-08-12)
6
+
7
+ * Fixed migration docs.
8
+
9
+ * Removed dependency on PGconn in Schema class.
10
+
1
11
  === 0.1.9.4 (2007-08-11)
2
12
 
3
13
  * Added Sequel.dbi convenience method for using DBI connection strings to open DBI databases.
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ require 'fileutils'
6
6
  include FileUtils
7
7
 
8
8
  NAME = "sequel"
9
- VERS = "0.1.9.4"
9
+ VERS = "0.1.9.5"
10
10
  CLEAN.include ['**/.*.sw?', 'pkg/*', '.config', 'doc/*', 'coverage/*']
11
11
  RDOC_OPTS = ['--quiet', '--title', "Sequel: Concise ORM for Ruby",
12
12
  "--opname", "index.html",
data/lib/sequel.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  require 'metaid'
2
2
 
3
3
  files = %w[
4
- core_ext error database connection_pool
5
- schema pretty_table expressions dataset migration model
4
+ core_ext error database connection_pool pretty_table expressions
5
+ dataset schema migration model
6
6
  ]
7
7
  dir = File.join(File.dirname(__FILE__), 'sequel')
8
8
  files.each {|f| require(File.join(dir, f))}
@@ -1,9 +1,5 @@
1
1
  require 'uri'
2
2
 
3
- require File.join(File.dirname(__FILE__), 'schema')
4
- require File.join(File.dirname(__FILE__), 'dataset')
5
- require File.join(File.dirname(__FILE__), 'model')
6
-
7
3
  module Sequel
8
4
  # A SingleThreadedPool acts as a replacement for a ConnectionPool for use
9
5
  # in single-threaded applications. ConnectionPool imposes a substantial
@@ -64,6 +64,8 @@ module Sequel
64
64
  when String: "'#{v.gsub(/'/, "''")}'"
65
65
  when Integer, Float: v.to_s
66
66
  when NilClass: NULL
67
+ when TrueClass: 't'
68
+ when FalseClass: 'f'
67
69
  when Symbol: v.to_field_name
68
70
  when Array: v.empty? ? NULL : v.map {|i| literal(i)}.join(COMMA_SEPARATOR)
69
71
  when Time: v.strftime(TIMESTAMP_FORMAT)
@@ -9,7 +9,7 @@ module Sequel
9
9
  # def up
10
10
  # create_table :sessions do
11
11
  # primary_key :id
12
- # varchar :session_id, :length => 32, :unique => true
12
+ # varchar :session_id, :size => 32, :unique => true
13
13
  # timestamp :created_at
14
14
  # text :data
15
15
  # end
@@ -116,7 +116,7 @@ module Sequel
116
116
  end
117
117
  end
118
118
 
119
- # Returns a list of migration classes filter for the migration range and
119
+ # Returns a list of migration classes filtered for the migration range and
120
120
  # ordered according to the migration direction.
121
121
  def self.migration_classes(directory, target, current, direction)
122
122
  range = direction == :up ?
@@ -145,6 +145,7 @@ module Sequel
145
145
  filtered ? filtered.compact : []
146
146
  end
147
147
 
148
+ # Returns the latest version available in the specified directory.
148
149
  def self.latest_migration_version(directory)
149
150
  l = migration_files(directory).last
150
151
  l ? File.basename(l).to_i : nil
data/lib/sequel/schema.rb CHANGED
@@ -1,8 +1,12 @@
1
1
  module Sequel
2
2
  class Schema
3
+ class << self
4
+ include Dataset::SQL
5
+ end
6
+
3
7
  COMMA_SEPARATOR = ', '.freeze
4
8
  COLUMN_DEF = '%s %s'.freeze
5
- SIZE_DEF = '(%d)'.freeze
9
+ COLUMN_MEMBERS_DEF = '(%d)'.freeze
6
10
  UNIQUE = ' UNIQUE'.freeze
7
11
  NOT_NULL = ' NOT NULL'.freeze
8
12
  DEFAULT = ' DEFAULT %s'.freeze
@@ -33,10 +37,11 @@ module Sequel
33
37
  def self.column_definition(column)
34
38
  c = COLUMN_DEF % [column[:name], TYPES[column[:type]]]
35
39
  column[:size] ||= 255 if column[:type] == :varchar
36
- c << SIZE_DEF % column[:size] if column[:size]
40
+ atts = column[:size] || column[:elements]
41
+ c << COLUMN_MEMBERS_DEF % literal(atts) if atts
37
42
  c << UNIQUE if column[:unique]
38
43
  c << NOT_NULL if column[:null] == false
39
- c << DEFAULT % PGconn.quote(column[:default]) if column.include?(:default)
44
+ c << DEFAULT % literal(column[:default]) if column.include?(:default)
40
45
  c << PRIMARY_KEY if column[:primary_key]
41
46
  c << REFERENCES % column[:table] if column[:table]
42
47
  c << ON_DELETE % on_delete_action(column[:on_delete]) if
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: sequel
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.9.4
6
+ version: 0.1.9.5
7
7
  date: 2007-08-11 00:00:00 +03:00
8
8
  summary: Concise ORM for Ruby.
9
9
  require_paths:
@@ -33,6 +33,7 @@ files:
33
33
  - README
34
34
  - Rakefile
35
35
  - bin/sequel
36
+ - doc/rdoc
36
37
  - spec/adapters
37
38
  - spec/connection_pool_spec.rb
38
39
  - spec/core_ext_spec.rb