dbd-sqlanywhere 0.1.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,26 +1,26 @@
1
- DBDConfig.set_testbase(:sqlanywhere, Class.new(Test::Unit::TestCase) do
2
- def dbtype
3
- "sqlanywhere"
4
- end
5
-
6
- def test_base
7
- assert_equal(@dbh.driver_name, "SQLAnywhere")
8
- assert_kind_of(DBI::DBD::SQLAnywhere::Database, @dbh.instance_variable_get(:@handle))
9
- end
10
-
11
- def set_base_dbh
12
- config = DBDConfig.get_config["sqlanywhere"]
13
- @dbh = DBI.connect("dbi:SQLAnywhere:"+config["dbname"], config["username"], config["password"], { })
14
- end
15
-
16
- def setup
17
- set_base_dbh
18
- DBDConfig.inject_sql(@dbh, dbtype, "dbd/sqlanywhere/up.sql")
19
- end
20
-
21
- def teardown
22
- DBDConfig.inject_sql(@dbh, dbtype, "dbd/sqlanywhere/down.sql")
23
- @dbh.disconnect
24
- end
25
- end
26
- )
1
+ DBDConfig.set_testbase(:sqlanywhere, Class.new(Test::Unit::TestCase) do
2
+ def dbtype
3
+ "sqlanywhere"
4
+ end
5
+
6
+ def test_base
7
+ assert_equal(@dbh.driver_name, "SQLAnywhere")
8
+ assert_kind_of(DBI::DBD::SQLAnywhere::Database, @dbh.instance_variable_get(:@handle))
9
+ end
10
+
11
+ def set_base_dbh
12
+ config = DBDConfig.get_config["sqlanywhere"]
13
+ @dbh = DBI.connect("dbi:SQLAnywhere:"+config["dbname"], config["username"], config["password"], { })
14
+ end
15
+
16
+ def setup
17
+ set_base_dbh
18
+ DBDConfig.inject_sql(@dbh, dbtype, "dbd/sqlanywhere/up.sql")
19
+ end
20
+
21
+ def teardown
22
+ DBDConfig.inject_sql(@dbh, dbtype, "dbd/sqlanywhere/down.sql")
23
+ @dbh.disconnect
24
+ end
25
+ end
26
+ )
@@ -1,19 +1,19 @@
1
- drop view view_names;
2
- ---
3
- drop table names;
4
- ---
5
- drop table blob_test;
6
- ---
7
- drop table boolean_test;
8
- ---
9
- drop table time_test;
10
- ---
11
- drop table timestamp_test;
12
- ---
13
- drop table bit_test;
14
- ---
15
- drop table field_types_test;
16
- ---
17
- drop table db_specific_types_test;
18
- ---
19
- drop table precision_test;
1
+ drop view view_names;
2
+ ---
3
+ drop table names;
4
+ ---
5
+ drop table blob_test;
6
+ ---
7
+ drop table boolean_test;
8
+ ---
9
+ drop table time_test;
10
+ ---
11
+ drop table timestamp_test;
12
+ ---
13
+ drop table bit_test;
14
+ ---
15
+ drop table field_types_test;
16
+ ---
17
+ drop table db_specific_types_test;
18
+ ---
19
+ drop table precision_test;
@@ -1,28 +1,28 @@
1
- create table names (
2
- name varchar(255),
3
- age integer
4
- );
5
- ---
6
- insert into names (name, age) values ('Joe', 19);
7
- ---
8
- insert into names (name, age) values ('Jim', 30);
9
- ---
10
- insert into names (name, age) values ('Bob', 21);
11
- ---
12
- create table precision_test (text_field varchar(20) primary key not null, integer_field decimal(2,1));
13
- ---
14
- CREATE TABLE blob_test (name VARCHAR(30), data long binary);
15
- ---
16
- create view view_names as select * from names;
17
- ---
18
- create table boolean_test (num integer, mybool bit);
19
- ---
20
- create table time_test (mytime time);
21
- ---
22
- create table timestamp_test (mytimestamp timestamp);
23
- ---
24
- create table bit_test (mybit bit);
25
- ---
26
- create table field_types_test (foo integer not null primary key default 1);
27
- ---
28
- create table db_specific_types_test (ts timestamp, dt date);
1
+ create table names (
2
+ name varchar(255),
3
+ age integer
4
+ );
5
+ ---
6
+ insert into names (name, age) values ('Joe', 19);
7
+ ---
8
+ insert into names (name, age) values ('Jim', 30);
9
+ ---
10
+ insert into names (name, age) values ('Bob', 21);
11
+ ---
12
+ create table precision_test (text_field varchar(20) primary key not null, integer_field integer, decimal_field decimal(2,1), numeric_field numeric(30,6));
13
+ ---
14
+ CREATE TABLE blob_test (name VARCHAR(30), data long binary);
15
+ ---
16
+ create view view_names as select * from names;
17
+ ---
18
+ create table boolean_test (num integer, mybool bit);
19
+ ---
20
+ create table time_test (mytime time);
21
+ ---
22
+ create table timestamp_test (mytimestamp timestamp);
23
+ ---
24
+ create table bit_test (mybit bit);
25
+ ---
26
+ create table field_types_test (foo integer not null primary key default 1);
27
+ ---
28
+ create table db_specific_types_test (ts timestamp, dt date);
metadata CHANGED
@@ -1,86 +1,96 @@
1
- --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.4
3
- specification_version: 1
1
+ --- !ruby/object:Gem::Specification
4
2
  name: dbd-sqlanywhere
5
- version: !ruby/object:Gem::Version
6
- version: 0.1.2
7
- date: 2009-03-27 00:00:00 -04:00
8
- summary: Ruby DBI driver (DBD) for SQL Anywhere
9
- require_paths:
10
- - lib
11
- email: eric.farrar@ianywhere.com
12
- homepage: http://sqlanywhere.rubyforge.org
13
- rubyforge_project: sqlanywhere
14
- description: Ruby DBI driver (DBD) for SQL Anywhere
15
- autorequire:
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 1.8.6
24
- version:
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
25
6
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
- authors:
7
+ authors:
30
8
  - Eric Farrar
31
- files:
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: sqlanywhere
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.1.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.1.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: dbi
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 0.4.0
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.4.0
46
+ description: ! ' Ruby DBI driver (DBD) for SQL Anywhere
47
+
48
+ '
49
+ email: eric.farrar@ianywhere.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files:
53
+ - README
54
+ - CHANGELOG
55
+ - LICENSE
56
+ files:
32
57
  - lib/dbd/sqlanywhere/database.rb
33
58
  - lib/dbd/sqlanywhere/driver.rb
34
59
  - lib/dbd/sqlanywhere/statement.rb
35
60
  - lib/dbd/SQLAnywhere.rb
36
- - test/dbd
37
- - test/dbd/general
38
- - test/dbd/general/test_database.rb
39
- - test/dbd/general/test_statement.rb
40
- - test/dbd/general/test_types.rb
41
- - test/dbd/sqlanywhere
42
61
  - test/dbd/sqlanywhere/base.rb
43
62
  - test/dbd/sqlanywhere/down.sql
44
63
  - test/dbd/sqlanywhere/up.sql
45
- - test/DBD_TESTS
46
- - test/ts_dbd.rb
47
64
  - README
48
65
  - CHANGELOG
49
66
  - LICENSE
50
- test_files: []
51
-
52
- rdoc_options:
67
+ homepage: http://sqlanywhere.rubyforge.org
68
+ licenses: []
69
+ post_install_message:
70
+ rdoc_options:
53
71
  - --title
54
72
  - SQL Anywhere DBD for Ruby-DBI
55
73
  - --main
56
74
  - README
57
75
  - --line-numbers
58
- extra_rdoc_files:
59
- - README
60
- - CHANGELOG
61
- - LICENSE
62
- executables: []
63
-
64
- extensions: []
65
-
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: 1.8.6
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
66
90
  requirements: []
67
-
68
- dependencies:
69
- - !ruby/object:Gem::Dependency
70
- name: sqlanywhere
71
- version_requirement:
72
- version_requirements: !ruby/object:Gem::Version::Requirement
73
- requirements:
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- version: 0.1.0
77
- version:
78
- - !ruby/object:Gem::Dependency
79
- name: dbi
80
- version_requirement:
81
- version_requirements: !ruby/object:Gem::Version::Requirement
82
- requirements:
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- version: 0.4.0
86
- version:
91
+ rubyforge_project: sqlanywhere
92
+ rubygems_version: 1.8.24
93
+ signing_key:
94
+ specification_version: 3
95
+ summary: Ruby DBI driver (DBD) for SQL Anywhere
96
+ test_files: []
data/test/DBD_TESTS DELETED
@@ -1,48 +0,0 @@
1
- ================================================================================
2
- Using DBD tests
3
- ================================================================================
4
-
5
- Create a YAML file named .ruby-dbi.test-config.yaml in your home directory.
6
-
7
- This file is a hash of keys that determine what you want to test and how you
8
- access the databases related to those tests.
9
-
10
- The key 'dbtypes' is an array which determines what tests you want to run. They
11
- *do not* correspond to the driver names, they correspond to the test
12
- directories that were made for them.
13
-
14
- Each 'dbtype' has a key that contains a hash of values:
15
- - username: the username of your account
16
- - password: the password for your account
17
- - dbname: the name of the database to connect to
18
-
19
- NOTE that tests expect to connect to a database on localhost currently. This
20
- may be fixed in the future, especially when we start writing Oracle and
21
- SQLServer tests.
22
-
23
- Each DBD test relies on database semantics which may not match up entirely with
24
- this configuration. For instance, the postgresql tests expect you to be able to
25
- work with the database directly via the `psql' client. This is something which
26
- will eventually be remedied as time and ability allows.
27
-
28
- Here is a sample configuration to get you started with the postgresql tests:
29
-
30
- ################################################################################
31
-
32
- ---
33
- dbtypes:
34
- - postgresql
35
- postgresql:
36
- username: erikh
37
- password: monkeys
38
- dbname: rubytest
39
-
40
- ################################################################################
41
-
42
- NOTE the --- is part of the file and is not a separator.
43
-
44
- ================================================================================
45
- Writing DBD tests
46
- ================================================================================
47
-
48
- Coming soon.
@@ -1,157 +0,0 @@
1
- @class = Class.new(DBDConfig.testbase(DBDConfig.current_dbtype)) do
2
- def test_ping
3
- assert @dbh.ping
4
- # XXX if it isn't obvious, this should be tested better. Not sure what
5
- # good behavior is yet.
6
- end
7
-
8
- def test_columns
9
- assert_nothing_raised do
10
- cols = @dbh.columns("precision_test")
11
-
12
- assert(cols)
13
- assert_kind_of(Array, cols)
14
- assert_equal(2, cols.length)
15
-
16
- # the first column should always be "text_field" and have the following
17
- # properties:
18
- assert_equal("text_field", cols[0]["name"])
19
- assert(!cols[0]["nullable"])
20
-
21
- assert_equal(20, cols[0]["precision"])
22
- # scale can be either nil or 0 for character types.
23
- case cols[0]["scale"]
24
- when nil
25
- assert_equal(nil, cols[0]["scale"])
26
- when 0
27
- assert_equal(0, cols[0]["scale"])
28
- else
29
- flunk "scale can be either 0 or nil for character types"
30
- end
31
-
32
- assert_equal(
33
- DBI::Type::Varchar,
34
- DBI::TypeUtil.type_name_to_module(cols[0]["type_name"])
35
- )
36
-
37
- # the second column should always be "integer_field" and have the following
38
- # properties:
39
- assert_equal("integer_field", cols[1]["name"])
40
- assert(cols[1]["nullable"])
41
- assert_equal(1, cols[1]["scale"])
42
- assert_equal(2, cols[1]["precision"])
43
- assert_equal(
44
- DBI::Type::Decimal,
45
- DBI::TypeUtil.type_name_to_module(cols[1]["type_name"])
46
- )
47
-
48
- # finally, we ensure that every column in the array is a ColumnInfo
49
- # object
50
- cols.each { |col| assert_kind_of(DBI::ColumnInfo, col) }
51
- end
52
- end
53
-
54
- def test_prepare
55
- @sth = @dbh.prepare('select * from names')
56
-
57
- assert @sth
58
- assert_kind_of DBI::StatementHandle, @sth
59
-
60
- @sth.finish
61
- end
62
-
63
- def test_do
64
- assert_equal 1, @dbh.do("insert into names (name, age) values (?, ?)", "Billy", 21)
65
- @sth = @dbh.prepare("select * from names where name = ?")
66
- @sth.execute("Billy")
67
- assert_equal ["Billy", 21], @sth.fetch
68
- @sth.finish
69
- end
70
-
71
- def test_tables
72
- tables = @dbh.tables.sort
73
-
74
- # since this is a general test, let's prune the system tables
75
- # FIXME not so sure if this should be a general test anymore.
76
- if dbtype == "odbc"
77
- tables -= [
78
- "administrable_role_authorizations",
79
- "applicable_roles",
80
- "attributes",
81
- "check_constraint_routine_usage",
82
- "check_constraints",
83
- "column_domain_usage",
84
- "column_privileges",
85
- "column_udt_usage",
86
- "columns",
87
- "constraint_column_usage",
88
- "constraint_table_usage",
89
- "data_type_privileges",
90
- "domain_constraints",
91
- "domain_udt_usage",
92
- "domains",
93
- "element_types",
94
- "enabled_roles",
95
- "information_schema_catalog_name",
96
- "key_column_usage",
97
- "parameters",
98
- "referential_constraints",
99
- "role_column_grants",
100
- "role_routine_grants",
101
- "role_table_grants",
102
- "role_usage_grants",
103
- "routine_privileges",
104
- "routines",
105
- "schemata",
106
- "sequences",
107
- "sql_features",
108
- "sql_implementation_info",
109
- "sql_languages",
110
- "sql_packages",
111
- "sql_parts",
112
- "sql_sizing",
113
- "sql_sizing_profiles",
114
- "table_constraints",
115
- "table_privileges",
116
- "tables",
117
- "triggered_update_columns",
118
- "triggers",
119
- "usage_privileges",
120
- "view_column_usage",
121
- "view_routine_usage",
122
- "view_table_usage",
123
- "views"
124
- ]
125
- end
126
-
127
- case dbtype
128
- when "postgresql"
129
- tables.reject! { |x| x =~ /^pg_/ }
130
- assert_equal %w(array_test bit_test blob_test boolean_test bytea_test db_specific_types_test field_types_test names precision_test time_test timestamp_test view_names), tables
131
- else
132
- assert_equal %w(bit_test blob_test boolean_test db_specific_types_test field_types_test names precision_test time_test timestamp_test view_names), tables
133
- end
134
- end
135
-
136
- def test_attrs
137
- # test defaults
138
- assert @dbh["AutoCommit"] # should be true
139
-
140
- # test setting
141
- assert !(@dbh["AutoCommit"] = false)
142
- assert !@dbh["AutoCommit"]
143
-
144
- # test committing an outstanding transaction
145
-
146
- @sth = @dbh.prepare("insert into names (name, age) values (?, ?)")
147
- @sth.execute("Billy", 22)
148
- @sth.finish
149
-
150
- assert @dbh["AutoCommit"] = true # should commit at this point
151
-
152
- @sth = @dbh.prepare("select * from names where name = ?")
153
- @sth.execute("Billy")
154
- assert_equal [ "Billy", 22 ], @sth.fetch
155
- @sth.finish
156
- end
157
- end