ruby-odbc 0.99994 → 0.99995

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c7479d33fa9c59ff9ddceda117a54eff5b755a40
4
+ data.tar.gz: ffe877023d88272ddb59da531bf1fda03cdf6c35
5
+ SHA512:
6
+ metadata.gz: 95b9dd91fe942297cd879cfc83c82af7fe9a2aeaabcff01a65a9870b89886e8a7d729f8a2119241d46363282081bfeb9d8c0a21daf8836b619807deea947d0e8
7
+ data.tar.gz: 328aa7cff9af2f30af215560abc65d947879468299e31e449d7c919cb146a84effde0f88e9816fd7633230c70ecded79417db8dae00d1cb882f76b114f2d6040
data/ChangeLog CHANGED
@@ -1,6 +1,12 @@
1
1
  ODBC binding for Ruby
2
2
  ---------------------
3
3
 
4
+ Wed Mar 13 2013 version 0.99995 released
5
+
6
+ * added ODBC::Database.use_sql_column_name= flag to switch
7
+ usage of SQLColAttributes(SQL_COLUMN_LABEL) to
8
+ SQLColAttributes(SQL_COLUMN_NAME) on per connection basis
9
+
4
10
  Sat Jan 15 2011 version 0.99994 released
5
11
 
6
12
  * fixed column key caching, thanks Sean Noonan for bug report
data/README CHANGED
@@ -1,6 +1,6 @@
1
- # $Id: README,v 1.41 2011/01/15 08:03:22 chw Exp chw $
1
+ # $Id: README,v 1.42 2013/03/13 19:24:03 chw Exp chw $
2
2
 
3
- ruby-odbc-0.99994
3
+ ruby-odbc-0.99995
4
4
 
5
5
  This is an ODBC binding for Ruby. So far it has been tested with
6
6
 
@@ -18,6 +18,8 @@ This is an ODBC binding for Ruby. So far it has been tested with
18
18
 
19
19
  - Ruby 1.8.*, SQLite/ODBC >= 0.67, libiodbc 3.52.4 on Fedora Core 3 x86
20
20
 
21
+ - Ruby 2.0.0, SQLite/ODBC >= 0.93, unixODBC 2.2.14 on Ubuntu 12.04 x86
22
+
21
23
  Michael Neumann <neumann@s-direktnet.de> and
22
24
  Will Merrell <wmerrell@catalystcorp.com> reported successful compilation
23
25
  with Cygwin on Win32.
@@ -27,7 +27,7 @@
27
27
  <body>
28
28
  <h1><a name="reference">Ruby ODBC Reference</a></h1>
29
29
  <div class = "lastmodifed">
30
- Last update: Thu, 16 September 2010
30
+ Last update: Wed, 13 March 2013
31
31
  </div>
32
32
  <hr>
33
33
  <div>
@@ -706,6 +706,12 @@ aproc.statement.drop</pre>
706
706
  SQL_TIMESTAMP data types to Ruby objects. When true,
707
707
  Ruby Date and Time objects are represented in UTC, when
708
708
  false (default) in the local timezone.
709
+ <dt><a name="use_sql_column_name">
710
+ <code>use_sql_column_name[=<var>bool</var>]</code></a>
711
+ <dd>Sets or queries the flag controlling how column names are
712
+ read from the data source. When false (default), the ODBC
713
+ API <code>SQLColAttributes(SQL_COLUMN_LABEL)</code> is used,
714
+ otherwise <code>SQLColAttributes(SQL_COLUMN_NAME)</code> is used.
709
715
  </dl>
710
716
  <h3>singleton methods:</h3>
711
717
  <dl>
data/ext/odbc.c CHANGED
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * ODBC-Ruby binding
3
- * Copyright (c) 2001-2011 Christian Werner <chw@ch-werner.de>
3
+ * Copyright (c) 2001-2013 Christian Werner <chw@ch-werner.de>
4
4
  * Portions copyright (c) 2004 Ryszard Niewisiewicz <micz@fibernet.pl>
5
5
  * Portions copyright (c) 2006 Carl Blakeley <cblakeley@openlinksw.co.uk>
6
6
  *
@@ -8,7 +8,7 @@
8
8
  * and redistribution of this file and for a
9
9
  * DISCLAIMER OF ALL WARRANTIES.
10
10
  *
11
- * $Id: odbc.c,v 1.72 2011/01/15 08:02:55 chw Exp chw $
11
+ * $Id: odbc.c,v 1.75 2013/03/13 19:31:13 chw Exp chw $
12
12
  */
13
13
 
14
14
  #undef ODBCVER
@@ -168,6 +168,7 @@ typedef struct dbc {
168
168
  VALUE rbtime;
169
169
  VALUE gmtime;
170
170
  int upc;
171
+ VALUE use_sql_column_name;
171
172
  } DBC;
172
173
 
173
174
  typedef struct {
@@ -1954,6 +1955,7 @@ dbc_new(int argc, VALUE *argv, VALUE self)
1954
1955
  list_init(&p->stmts, offsetof(STMT, link));
1955
1956
  p->hdbc = SQL_NULL_HDBC;
1956
1957
  p->upc = 0;
1958
+ p->use_sql_column_name = Qfalse;
1957
1959
  #endif
1958
1960
  if (env != Qnil) {
1959
1961
  ENV *e;
@@ -2194,6 +2196,20 @@ dbc_timeutc(int argc, VALUE *argv, VALUE self)
2194
2196
  }
2195
2197
  return p->gmtime;
2196
2198
  }
2199
+
2200
+ static VALUE
2201
+ dbc_use_scn(int argc, VALUE *argv, VALUE self)
2202
+ {
2203
+ DBC *p = get_dbc(self);
2204
+ VALUE val;
2205
+
2206
+ if (argc > 0) {
2207
+ rb_scan_args(argc, argv, "1", &val);
2208
+ p->use_sql_column_name =
2209
+ (val != Qnil && val != Qfalse) ? Qtrue : Qfalse;
2210
+ }
2211
+ return p->use_sql_column_name;
2212
+ }
2197
2213
 
2198
2214
  /*
2199
2215
  *----------------------------------------------------------------------
@@ -3183,7 +3199,7 @@ make_coltypes(SQLHSTMT hstmt, int ncols, char **msgp)
3183
3199
  {
3184
3200
  int i;
3185
3201
  COLTYPE *ret = NULL;
3186
- SQLLEN type, size;
3202
+ SQLLEN type, size = 0;
3187
3203
 
3188
3204
  for (i = 0; i < ncols; i++) {
3189
3205
  SQLUSMALLINT ic = i + 1;
@@ -3565,7 +3581,7 @@ upcase_if(char *string, int upc)
3565
3581
  */
3566
3582
 
3567
3583
  static VALUE
3568
- make_column(SQLHSTMT hstmt, int i, int upc)
3584
+ make_column(SQLHSTMT hstmt, int i, int upc, int use_scn)
3569
3585
  {
3570
3586
  VALUE obj, v;
3571
3587
  SQLUSMALLINT ic = i + 1;
@@ -3580,10 +3596,12 @@ make_column(SQLHSTMT hstmt, int i, int upc)
3580
3596
 
3581
3597
  name[0] = 0;
3582
3598
  if (!succeeded(SQL_NULL_HENV, SQL_NULL_HDBC, hstmt,
3583
- SQLColAttributes(hstmt, ic, SQL_COLUMN_LABEL, name,
3599
+ SQLColAttributes(hstmt, ic, use_scn ? SQL_COLUMN_NAME :
3600
+ SQL_COLUMN_LABEL, name,
3584
3601
  (SQLSMALLINT) sizeof (name),
3585
3602
  &name_len, NULL),
3586
- &msg, "SQLColAttributes(SQL_COLUMN_LABEL)")) {
3603
+ &msg, use_scn ? "SQLColAttributes(SQL_COLUMN_NAME)" :
3604
+ "SQLColAttributes(SQL_COLUMN_LABEL)")) {
3587
3605
  rb_raise(Cerror, "%s", msg);
3588
3606
  }
3589
3607
  obj = rb_obj_alloc(Ccolumn);
@@ -5823,27 +5841,34 @@ stmt_column(int argc, VALUE *argv, VALUE self)
5823
5841
  {
5824
5842
  STMT *q;
5825
5843
  VALUE col;
5844
+ int use_scn = 0;
5826
5845
 
5827
5846
  rb_scan_args(argc, argv, "1", &col);
5828
5847
  Check_Type(col, T_FIXNUM);
5829
5848
  Data_Get_Struct(self, STMT, q);
5830
5849
  check_ncols(q);
5831
- return make_column(q->hstmt, FIX2INT(col), q->upc);
5850
+ if (q->dbcp != NULL && q->dbcp->use_sql_column_name == Qtrue) {
5851
+ use_scn = 1;
5852
+ }
5853
+ return make_column(q->hstmt, FIX2INT(col), q->upc, use_scn);
5832
5854
  }
5833
5855
 
5834
5856
  static VALUE
5835
5857
  stmt_columns(int argc, VALUE *argv, VALUE self)
5836
5858
  {
5837
5859
  STMT *q;
5838
- int i;
5860
+ int i, use_scn = 0;
5839
5861
  VALUE res, as_ary = Qfalse;
5840
5862
 
5841
5863
  rb_scan_args(argc, argv, "01", &as_ary);
5842
5864
  Data_Get_Struct(self, STMT, q);
5843
5865
  check_ncols(q);
5866
+ if (q->dbcp != NULL && q->dbcp->use_sql_column_name == Qtrue) {
5867
+ use_scn = 1;
5868
+ }
5844
5869
  if (rb_block_given_p()) {
5845
5870
  for (i = 0; i < q->ncols; i++) {
5846
- rb_yield(make_column(q->hstmt, i, q->upc));
5871
+ rb_yield(make_column(q->hstmt, i, q->upc, use_scn));
5847
5872
  }
5848
5873
  return self;
5849
5874
  }
@@ -5855,7 +5880,7 @@ stmt_columns(int argc, VALUE *argv, VALUE self)
5855
5880
  for (i = 0; i < q->ncols; i++) {
5856
5881
  VALUE obj;
5857
5882
 
5858
- obj = make_column(q->hstmt, i, q->upc);
5883
+ obj = make_column(q->hstmt, i, q->upc, use_scn);
5859
5884
  if (RTEST(as_ary)) {
5860
5885
  rb_ary_store(res, i, obj);
5861
5886
  } else {
@@ -5918,7 +5943,7 @@ stmt_params(VALUE self)
5918
5943
  static VALUE
5919
5944
  do_fetch(STMT *q, int mode)
5920
5945
  {
5921
- int i, offc;
5946
+ int i, use_scn = 0, offc;
5922
5947
  char **bufs, *msg;
5923
5948
  VALUE res;
5924
5949
 
@@ -5958,6 +5983,9 @@ do_fetch(STMT *q, int mode)
5958
5983
  }
5959
5984
  }
5960
5985
  }
5986
+ if (q->dbcp != NULL && q->dbcp->use_sql_column_name == Qtrue) {
5987
+ use_scn = 1;
5988
+ }
5961
5989
  switch (mode & DOFETCH_MODES) {
5962
5990
  case DOFETCH_HASH:
5963
5991
  case DOFETCH_HASH2:
@@ -6008,10 +6036,13 @@ do_fetch(STMT *q, int mode)
6008
6036
  if (!succeeded(SQL_NULL_HENV, SQL_NULL_HDBC, q->hstmt,
6009
6037
  SQLColAttributes(q->hstmt,
6010
6038
  (SQLUSMALLINT) (i + 1),
6039
+ use_scn ? SQL_COLUMN_NAME :
6011
6040
  SQL_COLUMN_LABEL, name,
6012
6041
  sizeof (name),
6013
6042
  &name_len, NULL),
6014
- &msg, "SQLColAttributes(SQL_COLUMN_LABEL)")) {
6043
+ &msg, use_scn ?
6044
+ "SQLColAttributes(SQL_COLUMN_NAME)" :
6045
+ "SQLColAttributes(SQL_COLUMN_LABEL)")) {
6015
6046
  rb_raise(Cerror, "%s", msg);
6016
6047
  }
6017
6048
  if (name_len >= (SQLSMALLINT) sizeof (name)) {
@@ -6064,8 +6095,10 @@ do_fetch(STMT *q, int mode)
6064
6095
  name[0] = 0;
6065
6096
  callsql(SQL_NULL_HENV, SQL_NULL_HDBC, q->hstmt,
6066
6097
  SQLColAttributes(q->hstmt, (SQLUSMALLINT) (i + 1),
6098
+ use_scn ? SQL_COLUMN_NAME :
6067
6099
  SQL_COLUMN_LABEL, name,
6068
6100
  sizeof (name), &name_len, NULL),
6101
+ use_scn ? "SQLColAttributes(SQL_COLUMN_NAME)" :
6069
6102
  "SQLColAttributes(SQL_COLUMN_LABEL)");
6070
6103
  if (name_len >= (SQLSMALLINT) sizeof (name)) {
6071
6104
  name_len = sizeof (name) - 1;
@@ -8247,6 +8280,8 @@ Init_odbc()
8247
8280
  rb_define_method(Cdbc, "use_time=", dbc_timefmt, -1);
8248
8281
  rb_define_method(Cdbc, "use_utc", dbc_timeutc, -1);
8249
8282
  rb_define_method(Cdbc, "use_utc=", dbc_timeutc, -1);
8283
+ rb_define_method(Cdbc, "use_sql_column_name", dbc_use_scn, -1);
8284
+ rb_define_method(Cdbc, "use_sql_column_name=", dbc_use_scn, -1);
8250
8285
 
8251
8286
  /* connection options */
8252
8287
  rb_define_method(Cdbc, "get_option", dbc_getsetoption, -1);
@@ -112,16 +112,16 @@ if PLATFORM =~ /mswin32/ then
112
112
  have_func("SQLReadFileDSNW", "odbcinst.h")
113
113
  have_func("SQLInstallerError", "odbcinst.h")
114
114
  have_func("SQLInstallerErrorW", "odbcinst.h")
115
- # mingw untested !!!
116
115
  elsif PLATFORM =~ /(mingw|cygwin)/ then
117
116
  have_library("odbc32", "")
118
117
  have_library("odbccp32", "")
119
118
  have_library("user32", "")
120
- have_func("SQLConfigDataSourceW", "odbcinst.h")
121
- have_func("SQLWriteFileDSNW", "odbcinst.h")
122
- have_func("SQLReadFileDSNW", "odbcinst.h")
123
- have_func("SQLInstallerError", "odbcinst.h")
124
- have_func("SQLInstallerErrorW", "odbcinst.h")
119
+ header = ["windows.h", "odbcinst.h"]
120
+ have_func("SQLConfigDataSourceW", header)
121
+ have_func("SQLWriteFileDSNW", header)
122
+ have_func("SQLReadFileDSNW", header)
123
+ have_func("SQLInstallerError", header)
124
+ have_func("SQLInstallerErrorW", header)
125
125
  elsif (testdlopen && PLATFORM !~ /(macos|darwin)/ && CONFIG["CC"] =~ /gcc/ && have_func("dlopen", "dlfcn.h") && have_library("dl", "dlopen")) then
126
126
  $LDFLAGS+=" -Wl,-init -Wl,ruby_odbc_init -Wl,-fini -Wl,ruby_odbc_fini"
127
127
  $CPPFLAGS+=" -DHAVE_SQLCONFIGDATASOURCE"
@@ -1,7 +1,7 @@
1
1
  require 'date'
2
2
  spec = Gem::Specification.new do |s|
3
3
  s.name = "ruby-odbc"
4
- s.version = "0.99994"
4
+ s.version = "0.99995"
5
5
  s.date = Date.today.to_s
6
6
  s.author = "Christian Werner"
7
7
  s.email = "chw @nospam@ ch-werner.de"
metadata CHANGED
@@ -1,91 +1,73 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ruby-odbc
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 99994
8
- version: "0.99994"
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.99995'
9
5
  platform: ruby
10
- authors:
6
+ authors:
11
7
  - Christian Werner
12
8
  autorequire:
13
9
  bindir: bin
14
10
  cert_chain: []
15
-
16
- date: 2011-01-15 00:00:00 +01:00
17
- default_executable:
11
+ date: 2013-03-13 00:00:00.000000000 Z
18
12
  dependencies: []
19
-
20
13
  description:
21
14
  email: chw @nospam@ ch-werner.de
22
15
  executables: []
23
-
24
- extensions:
16
+ extensions:
25
17
  - ext/extconf.rb
26
18
  - ext/utf8/extconf.rb
27
- extra_rdoc_files:
19
+ extra_rdoc_files:
28
20
  - README
29
21
  - COPYING
30
22
  - ChangeLog
31
23
  - GPL
32
24
  - doc/odbc.html
33
- files:
34
- - lib/cqgen.rb
35
- - doc/odbc.html
36
- - GPL
37
- - ruby-odbc.gemspec
38
- - ChangeLog
39
- - MANIFEST
40
- - README
25
+ files:
26
+ - COPYING
41
27
  - ext/init.c
28
+ - ext/extconf.rb
29
+ - ext/odbc.c
42
30
  - ext/utf8/init.c
43
31
  - ext/utf8/extconf.rb
44
32
  - ext/utf8/odbc.c
45
- - ext/extconf.rb
46
- - ext/odbc.c
47
- - test/utf8/test.rb
48
- - test/test.rb
49
- - test/70close.rb
33
+ - ruby-odbc.gemspec
34
+ - README
35
+ - MANIFEST
36
+ - doc/odbc.html
37
+ - ChangeLog
50
38
  - test/20insert.rb
51
- - test/30select.rb
52
39
  - test/10create_table.rb
53
- - test/00connect.rb
40
+ - test/test.rb
54
41
  - test/50drop_table.rb
42
+ - test/30select.rb
43
+ - test/utf8/test.rb
44
+ - test/70close.rb
55
45
  - test/40update.rb
56
- - COPYING
57
- has_rdoc: true
46
+ - test/00connect.rb
47
+ - lib/cqgen.rb
48
+ - GPL
58
49
  homepage: http://www.ch-werner.de/rubyodbc
59
50
  licenses: []
60
-
51
+ metadata: {}
61
52
  post_install_message:
62
53
  rdoc_options: []
63
-
64
- require_paths:
54
+ require_paths:
65
55
  - lib
66
56
  - lib
67
- required_ruby_version: !ruby/object:Gem::Requirement
68
- none: false
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- segments:
73
- - 0
74
- version: "0"
75
- required_rubygems_version: !ruby/object:Gem::Requirement
76
- none: false
77
- requirements:
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- segments:
81
- - 0
82
- version: "0"
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
83
67
  requirements: []
84
-
85
68
  rubyforge_project:
86
- rubygems_version: 1.3.7
69
+ rubygems_version: 2.0.0
87
70
  signing_key:
88
- specification_version: 3
71
+ specification_version: 4
89
72
  summary: ODBC binding for Ruby
90
73
  test_files: []
91
-