ar-sybase-jdbc-adapter 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,15 +1,20 @@
1
1
  = ar-sybase-jdbc-adapter
2
2
 
3
- ar-sybase-jdbc-adapter enhances the Arel 2 activerecord-jdbc-adapter to support "limit" and "offset" for Sybase ASE DB.
3
+ ar-sybase-jdbc-adapter enhances activerecord-jdbc-adapter (Rails 3) to support "limit" and "offset" for Sybase ASE DB.
4
4
 
5
5
  **This project is a proof of concept that Sybase ASE can work nicely with Rails**
6
+ Once the project reaches "close to production" functionality I will try to merge it with activerecord-jdbc-adapter
6
7
 
7
- Once the project reaches "close to production" functionality I will try to merge it with _activerecord-jdbc-adapter_
8
8
 
9
+ == Usage
10
+ 1. Install
9
11
 
12
+ gem install ar-sybase-jdbc-adapter
13
+
14
+ 2. Configuration
10
15
  To use this gem, set the "dialect" configuration parameter to "sybase_jtds".
16
+ Example:
11
17
 
12
- e.g.
13
18
  development:
14
19
  adapter: jdbc
15
20
  username: user_name
@@ -19,6 +24,7 @@ e.g.
19
24
  driver: net.sourceforge.jtds.jdbc.Driver
20
25
  url: jdbc:jtds:sybase://host:port/db_name
21
26
 
27
+
22
28
  == Offset in Sybase ASE
23
29
 
24
30
  Sybase is an awful DB in term of support for "offset". I found 2 ways to do it for generic queries:
@@ -77,8 +83,6 @@ fall back to `cursor` and get `@@rowcount` to get the number of rows.
77
83
 
78
84
 
79
85
 
80
-
81
-
82
86
  == Known issues
83
87
 
84
88
  I am aware of a very strange issue where the driver does not work when the very first query uses "limit()".
@@ -112,6 +116,6 @@ e.g.
112
116
 
113
117
  == Copyright
114
118
 
115
- Copyright (c) 2010 arkadiy kraportov. See LICENSE.txt for
119
+ Copyright (c) 2011 arkadiy kraportov. See LICENSE.txt for
116
120
  further details.
117
121
 
@@ -5,7 +5,7 @@ module Arel
5
5
  def select_count? o
6
6
  sel = o.cores.length == 1 && o.cores.first
7
7
  projections = sel.projections.length == 1 && sel.projections
8
- Arel::Nodes::Count === projections.first
8
+ Arel::Nodes::Count === (projections.respond_to?(:first) && projections.first)
9
9
  end
10
10
 
11
11
 
@@ -13,22 +13,21 @@ module Arel
13
13
  if o.offset || (o.limit && select_count?(o))
14
14
  o.offset.expr += 1 if o.offset
15
15
  sql = super # if offset OR (limit & count) use the Java limit/offset/count parser
16
- else
17
- limit = o.limit
16
+ elsif o.limit
17
+ limit = o.limit.expr
18
18
  o.limit = nil
19
19
  sql = super
20
-
21
- if limit
22
- limit_and_no_offset sql, limit
23
- end
20
+ limit_and_no_offset sql, limit
21
+ else
22
+ sql = super
24
23
  end
25
24
 
26
25
  sql
27
26
  end
28
27
 
29
28
  def limit_and_no_offset sql, limit
30
- if sql =~ /DISTINCT /
31
- sql.gsub!(/DISTINCT /, "DISTINCT TOP #{limit} ")
29
+ if sql =~ /DISTINCT /i
30
+ sql.gsub!(/DISTINCT /i, "DISTINCT TOP #{limit} ")
32
31
  else
33
32
  sql.gsub!(/SELECT /, "SELECT TOP #{limit} ")
34
33
  end
@@ -14,5 +14,10 @@ module ::ArJdbc
14
14
  def self.column_selector
15
15
  [/sybase/i, lambda {|cfg,col| col.extend(::ArJdbc::MsSQL::Column)}]
16
16
  end
17
+
18
+ def supports_migrations?
19
+ false
20
+ end
21
+
17
22
  end
18
23
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
8
- - 1
9
- version: 0.1.1
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - arkadiy kraportov
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-13 00:00:00 +09:00
17
+ date: 2011-01-17 00:00:00 +09:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -73,13 +73,13 @@ dependencies:
73
73
  name: arel
74
74
  version_requirements: &id005 !ruby/object:Gem::Requirement
75
75
  requirements:
76
- - - ">"
76
+ - - "="
77
77
  - !ruby/object:Gem::Version
78
78
  segments:
79
79
  - 2
80
80
  - 0
81
- - 0
82
- version: 2.0.0
81
+ - 7
82
+ version: 2.0.7
83
83
  requirement: *id005
84
84
  prerelease: false
85
85
  type: :development
@@ -87,13 +87,13 @@ dependencies:
87
87
  name: activerecord-jdbc-adapter
88
88
  version_requirements: &id006 !ruby/object:Gem::Requirement
89
89
  requirements:
90
- - - ">="
90
+ - - "="
91
91
  - !ruby/object:Gem::Version
92
92
  segments:
93
93
  - 1
94
94
  - 1
95
- - 0
96
- version: 1.1.0
95
+ - 1
96
+ version: 1.1.1
97
97
  requirement: *id006
98
98
  prerelease: false
99
99
  type: :development
@@ -120,8 +120,8 @@ dependencies:
120
120
  segments:
121
121
  - 1
122
122
  - 1
123
- - 0
124
- version: 1.1.0
123
+ - 1
124
+ version: 1.1.1
125
125
  requirement: *id008
126
126
  prerelease: false
127
127
  type: :runtime
@@ -134,8 +134,8 @@ dependencies:
134
134
  segments:
135
135
  - 2
136
136
  - 0
137
- - 6
138
- version: 2.0.6
137
+ - 7
138
+ version: 2.0.7
139
139
  requirement: *id009
140
140
  prerelease: false
141
141
  type: :runtime
@@ -211,7 +211,7 @@ rubyforge_project:
211
211
  rubygems_version: 1.3.6
212
212
  signing_key:
213
213
  specification_version: 3
214
- summary: Adds support for limit and offset for Sybase JDBC driver
214
+ summary: Adds support for limit and offset for Rails 3 and Sybase JDBC driver
215
215
  test_files:
216
216
  - test/helper.rb
217
217
  - test/support/fake_record.rb