nbadw-util 0.1.1 → 0.1.2

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.
@@ -0,0 +1,18 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'nbadw/util/copy_database_task'
5
+
6
+ src = 'jdbc:access:////home/colin/master.mdb'
7
+
8
+ db = Sequel.connect(src)
9
+
10
+ db.tables.each do |t|
11
+ puts t
12
+ end
13
+
14
+ puts db.dump_table_schema(:cdAgency)
15
+
16
+ db.schema(:cdAgency).each do |col_info|
17
+ puts "#{col_info[0]}: #{col_info[1].inspect}"
18
+ end
@@ -21,8 +21,7 @@ module Sequel
21
21
  Sequel::JDBC::Access::Dataset.new(self, opts)
22
22
  end
23
23
 
24
- private
25
-
24
+ private
26
25
  # Call the generic JDBC version instead of MSSQL version,
27
26
  # since the JDBC version handles primary keys.
28
27
  def schema_parse_table(table, opts={})
@@ -13,9 +13,13 @@ module Sequel
13
13
  def database_type
14
14
  :access
15
15
  end
16
+
17
+ def upcase_identifiers?
18
+ false
19
+ end
16
20
 
17
21
  def supports_savepoints?
18
- false
22
+ true
19
23
  end
20
24
 
21
25
  private
@@ -95,10 +99,10 @@ module Sequel
95
99
  m = output_identifier_meth
96
100
  m2 = input_identifier_meth
97
101
  ds = metadata_dataset.from(:information_schema__tables___t).
98
- join(:information_schema__columns___c, :table_catalog=>:table_catalog,
99
- :table_schema => :table_schema, :table_name => :table_name).
100
- select(:column_name___column, :data_type___db_type, :character_maximum_length___max_chars, :column_default___default, :is_nullable___allow_null).
101
- filter(:c__table_name=>m2.call(table_name.to_s))
102
+ join(:information_schema__columns___c, :table_catalog=>:table_catalog,
103
+ :table_schema => :table_schema, :table_name => :table_name).
104
+ select(:column_name___column, :data_type___db_type, :character_maximum_length___max_chars, :column_default___default, :is_nullable___allow_null).
105
+ filter(:c__table_name=>m2.call(table_name.to_s))
102
106
  if schema = opts[:schema] || default_schema
103
107
  ds.filter!(:table_schema=>schema)
104
108
  end
@@ -149,6 +153,10 @@ module Sequel
149
153
  WILDCARD = LiteralString.new('*').freeze
150
154
  CONSTANT_MAP = {:CURRENT_DATE=>'CAST(CURRENT_TIMESTAMP AS DATE)'.freeze, :CURRENT_TIME=>'CAST(CURRENT_TIMESTAMP AS TIME)'.freeze}
151
155
 
156
+ def identifier_output_method
157
+ :to_s
158
+ end
159
+
152
160
  # Split out from fetch rows to allow processing of JDBC result sets
153
161
  # that don't come from issuing an SQL string.
154
162
  def process_result_set(result)
@@ -156,7 +164,7 @@ module Sequel
156
164
  meta = result.getMetaData
157
165
  cols = []
158
166
  i = 0
159
- meta.getColumnCount.times{cols << [output_identifier(meta.getColumnLabel(i+=1)), i]}
167
+ meta.getColumnCount.times{cols << [output_identifier(meta.getColumnLabel(i+=1)).to_s.downcase.to_sym, i]}
160
168
  @columns = cols.map{|c| c.at(0)}
161
169
  row = {}
162
170
  blk = if @convert_types
@@ -166,7 +174,7 @@ module Sequel
166
174
  rescue
167
175
  # XXX: this is because HXTT driver throws an error here
168
176
  if n == :column_def && row[:type_name] == 'TIMESTAMP'
169
- row[:column_def] = nil
177
+ row[:column_def] = ''
170
178
  end
171
179
  end
172
180
  }
@@ -235,9 +243,9 @@ module Sequel
235
243
  def output(into, values)
236
244
  output = {}
237
245
  case values
238
- when Hash:
246
+ when Hash:
239
247
  output[:column_list], output[:select_list] = values.keys, values.values
240
- when Array:
248
+ when Array:
241
249
  output[:select_list] = values
242
250
  end
243
251
  output[:into] = into
@@ -267,21 +275,6 @@ module Sequel
267
275
  s = unlimited.where("BETWEEN (recno(), #{@opts[:offset] + 1}, #{@opts[:limit] + @opts[:offset]})")
268
276
  s.select_sql
269
277
  end
270
- # def select_sql
271
- # return super unless offset = @opts[:offset]
272
- # raise(Error, 'Access requires an order be provided if using an offset') unless order = @opts[:order]
273
- #
274
- # total_rows = unlimited.count
275
- # if @opts[:limit] + @opts[:offset] > total_rows
276
- # correction = @opts[:limit] + @opts[:offset] - total_rows
277
- # @opts[:limit] = @opts[:limit] - correction
278
- # end
279
- #
280
- # s0 = unlimited.limit(@opts[:limit] + @opts[:offset]).order(order)
281
- # s1 = unlimited.from(s0.as('s1')).limit(@opts[:limit]).reverse_order(order)
282
- # s2 = unlimited.from(s1.as('s2')).order(order)
283
- # s2.select_sql
284
- # end
285
278
 
286
279
  # The version of the database server.
287
280
  def server_version
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nbadw-util
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin Casey
@@ -36,6 +36,7 @@ files:
36
36
  - Rakefile
37
37
  - lib/nbadw/util/copy_database_task.rb
38
38
  - lib/nbadw/util/progress_bar.rb
39
+ - lib/scratch.rb
39
40
  - lib/sequel/adapters/jdbc/access.rb
40
41
  - lib/sequel/adapters/shared/access.rb
41
42
  - lib/sequel/jdbc_access_adapter.rb