sequel 4.23.0 → 4.24.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +26 -0
  3. data/Rakefile +1 -1
  4. data/doc/release_notes/4.24.0.txt +99 -0
  5. data/doc/sql.rdoc +10 -1
  6. data/lib/sequel/adapters/jdbc.rb +7 -0
  7. data/lib/sequel/adapters/jdbc/cubrid.rb +1 -1
  8. data/lib/sequel/adapters/jdbc/db2.rb +1 -1
  9. data/lib/sequel/adapters/jdbc/derby.rb +1 -1
  10. data/lib/sequel/adapters/jdbc/h2.rb +1 -1
  11. data/lib/sequel/adapters/jdbc/hsqldb.rb +1 -1
  12. data/lib/sequel/adapters/jdbc/mssql.rb +1 -1
  13. data/lib/sequel/adapters/jdbc/mysql.rb +2 -2
  14. data/lib/sequel/adapters/jdbc/oracle.rb +1 -1
  15. data/lib/sequel/adapters/jdbc/sqlanywhere.rb +1 -1
  16. data/lib/sequel/adapters/jdbc/sqlite.rb +1 -1
  17. data/lib/sequel/adapters/postgres.rb +14 -6
  18. data/lib/sequel/adapters/shared/mssql.rb +1 -1
  19. data/lib/sequel/core.rb +12 -1
  20. data/lib/sequel/database/connecting.rb +1 -2
  21. data/lib/sequel/extensions/pg_inet_ops.rb +200 -0
  22. data/lib/sequel/plugins/association_pks.rb +63 -18
  23. data/lib/sequel/plugins/auto_validations.rb +43 -9
  24. data/lib/sequel/plugins/class_table_inheritance.rb +236 -179
  25. data/lib/sequel/plugins/update_refresh.rb +26 -1
  26. data/lib/sequel/plugins/validation_helpers.rb +7 -2
  27. data/lib/sequel/version.rb +1 -1
  28. data/spec/adapters/oracle_spec.rb +1 -1
  29. data/spec/adapters/postgres_spec.rb +61 -0
  30. data/spec/core_extensions_spec.rb +5 -1
  31. data/spec/extensions/association_pks_spec.rb +73 -1
  32. data/spec/extensions/auto_validations_spec.rb +34 -0
  33. data/spec/extensions/class_table_inheritance_spec.rb +58 -54
  34. data/spec/extensions/pg_inet_ops_spec.rb +101 -0
  35. data/spec/extensions/spec_helper.rb +5 -5
  36. data/spec/extensions/update_refresh_spec.rb +12 -0
  37. data/spec/extensions/validation_helpers_spec.rb +7 -0
  38. data/spec/integration/plugin_test.rb +48 -13
  39. metadata +6 -4
  40. data/lib/sequel/adapters/db2.rb +0 -229
  41. data/lib/sequel/adapters/dbi.rb +0 -102
@@ -1,102 +0,0 @@
1
- require 'dbi'
2
- Sequel::Deprecation.deprecate 'The dbi adapter is deprecated and will be removed in a future version of Sequel. Please switch to another adapter.'
3
-
4
- module Sequel
5
- module DBI
6
- class Database < Sequel::Database
7
- set_adapter_scheme :dbi
8
-
9
- DBI_ADAPTERS = {
10
- :ado => "ADO",
11
- :db2 => "DB2",
12
- :frontbase => "FrontBase",
13
- :interbase => "InterBase",
14
- :msql => "Msql",
15
- :mysql => "Mysql",
16
- :odbc => "ODBC",
17
- :oracle => "Oracle",
18
- :pg => "pg",
19
- :proxy => "Proxy",
20
- :sqlite => "SQLite",
21
- :sqlrelay => "SQLRelay"
22
- }
23
-
24
- # Converts a uri to an options hash. These options are then passed
25
- # to a newly created database object.
26
- def self.uri_to_options(uri) # :nodoc:
27
- database = (m = /\/(.*)/.match(uri.path)) && (m[1])
28
- if m = /dbi-(.+)/.match(uri.scheme)
29
- adapter = DBI_ADAPTERS[m[1].to_sym] || m[1]
30
- database = "#{adapter}:dbname=#{database}"
31
- end
32
- {
33
- :user => uri.user,
34
- :password => uri.password,
35
- :host => uri.host,
36
- :port => uri.port,
37
- :database => database
38
- }
39
- end
40
-
41
- private_class_method :uri_to_options
42
-
43
- def connect(server)
44
- opts = server_opts(server)
45
- dbname = opts[:database]
46
- if dbname !~ /^DBI:/ then
47
- dbname = "DBI:#{dbname}"
48
- [:host, :port].each{|sym| dbname += ";#{sym}=#{opts[sym]}" unless blank_object?(opts[sym])}
49
- end
50
- ::DBI.connect(dbname, opts[:user], opts[:password])
51
- end
52
-
53
- def disconnect_connection(c)
54
- c.disconnect
55
- end
56
-
57
- def execute(sql, opts=OPTS)
58
- synchronize(opts[:server]) do |conn|
59
- r = log_yield(sql){conn.execute(sql)}
60
- yield(r) if block_given?
61
- r
62
- end
63
- end
64
-
65
- def execute_dui(sql, opts=OPTS)
66
- synchronize(opts[:server]){|conn| log_yield(sql){conn.do(sql)}}
67
- end
68
-
69
- private
70
-
71
- def adapter_initialize
72
- case @opts[:db_type]
73
- when 'mssql'
74
- Sequel.require 'adapters/shared/mssql'
75
- extend Sequel::MSSQL::DatabaseMethods
76
- extend_datasets Sequel::MSSQL::DatasetMethods
77
- end
78
- end
79
- end
80
-
81
- class Dataset < Sequel::Dataset
82
- Database::DatasetClass = self
83
-
84
- def fetch_rows(sql)
85
- execute(sql) do |s|
86
- begin
87
- columns = cols = s.column_names.map{|c| output_identifier(c)}
88
- @columns = columns
89
- s.fetch do |r|
90
- row = {}
91
- cols.each{|c| row[c] = r.shift}
92
- yield row
93
- end
94
- ensure
95
- s.finish rescue nil
96
- end
97
- end
98
- self
99
- end
100
- end
101
- end
102
- end