arboreal 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/arboreal/class_methods.rb +5 -5
- data/lib/arboreal/version.rb +1 -1
- data/spec/spec_helper.rb +8 -1
- metadata +2 -2
@@ -30,19 +30,19 @@ module Arboreal
|
|
30
30
|
# As a result, this *may* not work for DBMS that aren't explicitly supported.
|
31
31
|
#
|
32
32
|
def ancestry_extension_sql
|
33
|
-
sql =
|
34
|
-
when /mysql/i
|
33
|
+
sql = if connection.adapter_name == "MySQL"
|
35
34
|
<<-SQL
|
36
35
|
UPDATE _arboreals_ AS child
|
37
36
|
JOIN _arboreals_ AS parent ON parent.id = child.parent_id
|
38
37
|
SET child.ancestry_string = CONCAT(parent.ancestry_string, parent.id, '-')
|
39
38
|
WHERE child.ancestry_string IS NULL
|
40
39
|
SQL
|
41
|
-
|
40
|
+
elsif connection.adapter_name == "JDBC" && connection.config[:url] =~ /sqlserver/
|
42
41
|
<<-SQL
|
43
|
-
UPDATE
|
44
|
-
JOIN _arboreals_ AS parent ON parent.id = child.parent_id
|
42
|
+
UPDATE child
|
45
43
|
SET child.ancestry_string = (parent.ancestry_string + CAST(parent.id AS varchar) + '-')
|
44
|
+
FROM _arboreals_ AS child
|
45
|
+
JOIN _arboreals_ AS parent ON parent.id = child.parent_id
|
46
46
|
WHERE child.ancestry_string IS NULL
|
47
47
|
SQL
|
48
48
|
else # SQLite, PostgreSQL, most others (SQL-92)
|
data/lib/arboreal/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -23,14 +23,21 @@ DB_CONFIGS = {
|
|
23
23
|
:database => 'tmp/test.sqlite'
|
24
24
|
},
|
25
25
|
"mysql" => {
|
26
|
-
:database => 'weblog_development',
|
27
26
|
:host => 'localhost',
|
27
|
+
:database => 'weblog_development',
|
28
28
|
:username => 'blog',
|
29
29
|
:password => ''
|
30
30
|
},
|
31
31
|
"postgresql" => {
|
32
|
+
:host => 'localhost',
|
32
33
|
:database => 'weblog_development',
|
34
|
+
},
|
35
|
+
"jdbcmssql" => {
|
33
36
|
:host => 'localhost',
|
37
|
+
:port => 1433,
|
38
|
+
:database => 'weblog_development',
|
39
|
+
:username => 'blog',
|
40
|
+
:password => ''
|
34
41
|
}
|
35
42
|
}
|
36
43
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arboreal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Williams
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-04-
|
12
|
+
date: 2010-04-06 00:00:00 +10:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|