fossil 0.3.45 → 0.3.46
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/fossil.gemspec +4 -2
- data/lib/models/trip_leg.rb +0 -2
- data/lib/sequel/mysql_pervasive_adapter.rb +62 -0
- data/lib/sequel/sqlite_pervasive_adapter.rb +106 -0
- metadata +4 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.46
|
data/fossil.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{fossil}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.46"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Patrick Lardin, Daniel Sudol"]
|
12
|
-
s.date = %q{2010-04-
|
12
|
+
s.date = %q{2010-04-29}
|
13
13
|
s.description = %q{Access FOS/betrieve db with this Sequel based orm wrapper}
|
14
14
|
s.email = %q{plardin@xojet.com}
|
15
15
|
s.files = [
|
@@ -121,10 +121,12 @@ Gem::Specification.new do |s|
|
|
121
121
|
"lib/sequel/fos_dates.rb",
|
122
122
|
"lib/sequel/metaprogramming.rb",
|
123
123
|
"lib/sequel/model_patch.rb",
|
124
|
+
"lib/sequel/mysql_pervasive_adapter.rb",
|
124
125
|
"lib/sequel/pervasive_adapter.rb",
|
125
126
|
"lib/sequel/serializer/json_serializer.rb",
|
126
127
|
"lib/sequel/serializer/serializer.rb",
|
127
128
|
"lib/sequel/serializer/xml_serializer.rb",
|
129
|
+
"lib/sequel/sqlite_pervasive_adapter.rb",
|
128
130
|
"lib/serial_number.rb",
|
129
131
|
"spec/be_model_with_values_matcher.rb",
|
130
132
|
"spec/be_model_with_values_matcher_spec.rb",
|
data/lib/models/trip_leg.rb
CHANGED
@@ -18,9 +18,7 @@ class TripLeg < Sequel::Model(:'trip legs')
|
|
18
18
|
n_to_o :catering, :class=>:AirportService, :prefix=>'catering'
|
19
19
|
n_to_o :crew_limo, :class=>:AirportService, :prefix=>'crewlimo'
|
20
20
|
n_to_o :arrival_fbo, :class=>:AirportFbo, :prefix=>'fbo'
|
21
|
-
# alias :arrival_fbo :airport_fbo # TODO replace assoc name airport_fbo with arrival_fbo
|
22
21
|
n_to_o :departure_fbo, :class=>:AirportFbo, :prefix=>'fueler'
|
23
|
-
# alias :departure_fbo :fueler # TODO replace assoc name fueler with departure_fbo
|
24
22
|
n_to_o :leg_rate, :class=>:AircraftRate, :prefix=>'leg rate'
|
25
23
|
n_to_o :leg_requestor, :class=>:Passenger, :prefix=>'leg req'
|
26
24
|
n_to_o :pax_limo, :class=>:AirportService, :prefix=>'limo'
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module MySql
|
2
|
+
module Pervasive
|
3
|
+
module DatabaseMethods
|
4
|
+
|
5
|
+
def dataset(opts = nil)
|
6
|
+
ds = super
|
7
|
+
ds.extend(DatasetMethods)
|
8
|
+
ds
|
9
|
+
end
|
10
|
+
|
11
|
+
def select_fields(table, *fields)
|
12
|
+
dataset.select_fields(table, *fields)
|
13
|
+
end
|
14
|
+
|
15
|
+
# if its not windows/linux where pervasive db is running in tests
|
16
|
+
# modify the pervasive adapter to act more like mysql for certain things
|
17
|
+
def auto_increment_sql;"AUTO_INCREMENT"; end
|
18
|
+
def begin_transaction_sql; "BEGIN" end
|
19
|
+
def commit_transaction_sql; "COMMIT" end
|
20
|
+
def rollback_transaction_sql; "ROLLBACK" end
|
21
|
+
|
22
|
+
def get_column_type(column_name)
|
23
|
+
if model and model.respond_to?(:datatypes) and model.datatypes and model.datatypes[column_name]
|
24
|
+
return model.datatypes[column_name][:type]
|
25
|
+
end
|
26
|
+
nil
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
module DatasetMethods
|
32
|
+
|
33
|
+
def select_clause_methods
|
34
|
+
super
|
35
|
+
end
|
36
|
+
|
37
|
+
def select_limit_sql(sql)
|
38
|
+
super(sql)
|
39
|
+
end
|
40
|
+
|
41
|
+
def quoted_identifier(name, convert=true)
|
42
|
+
convert ? "`#{convert_aliased_col_to_real_col(name)}`" : "`#{name}`"
|
43
|
+
end
|
44
|
+
|
45
|
+
def convert_aliased_col_to_real_col(col_name)
|
46
|
+
if respond_to?(:model) and model.respond_to?(:aliases) and model.aliases
|
47
|
+
sym_name = col_name.to_s.downcase.to_sym
|
48
|
+
col_name = model.aliases[sym_name].to_s.upcase if model.aliases.include? sym_name
|
49
|
+
end
|
50
|
+
col_name
|
51
|
+
end
|
52
|
+
|
53
|
+
def convert_aliased_col_to_real_col_with_model(col_name, model)
|
54
|
+
if model.respond_to?(:aliases) and model.aliases
|
55
|
+
sym_name = col_name.to_s.downcase.to_sym
|
56
|
+
col_name = model.aliases[sym_name].to_s.upcase if model.aliases.include? sym_name
|
57
|
+
end
|
58
|
+
col_name
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
module Sqlite
|
2
|
+
module Pervasive
|
3
|
+
module DatabaseMethods
|
4
|
+
|
5
|
+
def dataset(opts = nil)
|
6
|
+
ds = super
|
7
|
+
ds.extend(DatasetMethods)
|
8
|
+
ds
|
9
|
+
end
|
10
|
+
|
11
|
+
def select_fields(table, *fields)
|
12
|
+
dataset.select_fields(table, *fields)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
module DatasetMethods
|
18
|
+
|
19
|
+
def get_column_type(column_name)
|
20
|
+
if model and model.respond_to?(:datatypes) and model.datatypes and model.datatypes[column_name]
|
21
|
+
return model.datatypes[column_name][:type]
|
22
|
+
end
|
23
|
+
nil
|
24
|
+
end
|
25
|
+
|
26
|
+
def quoted_identifier(name, convert=true)
|
27
|
+
convert ? "\"#{convert_aliased_col_to_real_col(name)}\"" : "\"#{name}\""
|
28
|
+
end
|
29
|
+
|
30
|
+
# Take a table name and write out the field names for that table in this style:
|
31
|
+
# "`DUDES`.`KID - DATE`".lit where the table name is :dudes,
|
32
|
+
# and fields are [:kid_date]
|
33
|
+
def select_fields(hash)
|
34
|
+
new_hash = Hash.new{|k, v| k[v]= {}}
|
35
|
+
|
36
|
+
hash.each do |association, fields|
|
37
|
+
new_hash[association][:fields] = fields
|
38
|
+
|
39
|
+
if association == :self
|
40
|
+
new_hash[association][:model] = self.model
|
41
|
+
new_hash[association][:association_name] = self.model.table_name
|
42
|
+
elsif association.to_s.match /(\w+)__(\w+)/ # crew_legs__position_code
|
43
|
+
# not an assocation on the current model .. but another one
|
44
|
+
new_hash[association][:association_name] = $2.to_s.upcase
|
45
|
+
new_hash[association][:model] = model.association_reflection($1.to_sym)[:class].association_reflection($2.to_sym)[:class]
|
46
|
+
else
|
47
|
+
raise(Sequel::Error, "Invalid #{model} association: #{association}") unless model.association_reflection(association)
|
48
|
+
new_hash[association][:association_name] = association.to_s.upcase
|
49
|
+
new_hash[association][:model] = model.association_reflection(association)[:class]
|
50
|
+
end
|
51
|
+
fields = fields + new_hash[association][:model].primary_key unless fields[0] == :*
|
52
|
+
new_hash[association][:fields] = fields
|
53
|
+
end
|
54
|
+
|
55
|
+
s = []
|
56
|
+
new_hash.each do |association, hash|
|
57
|
+
if hash[:fields].size == 1 and hash[:fields][0] == :*
|
58
|
+
s << "#{quoted_identifier(hash[:association_name], false)}.*".lit
|
59
|
+
else
|
60
|
+
s << hash[:fields].collect do |field|
|
61
|
+
raw_field_name = convert_aliased_col_to_real_col_with_model(field, hash[:model])
|
62
|
+
as_alias = ''
|
63
|
+
raw_field_name
|
64
|
+
|
65
|
+
if association != :self and ( hash[:model].primary_key.include? field or field_duplicate(new_hash, association, field) )
|
66
|
+
as_field_name = "#{hash[:association_name]}_#{raw_field_name}"
|
67
|
+
as_alias = "AS #{quoted_identifier(as_field_name, false)}"
|
68
|
+
end
|
69
|
+
"#{quoted_identifier(hash[:association_name], false)}.#{quoted_identifier(raw_field_name, false)} #{as_alias}".lit
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
clone(:select => s.flatten)
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
# is the field name found in the fields of any other association besides the one you passed in
|
80
|
+
def field_duplicate(hash, association, field)
|
81
|
+
hash.each do |association_key, hash_values|
|
82
|
+
next if association_key == association
|
83
|
+
return true if hash_values[:fields].include? field
|
84
|
+
end
|
85
|
+
return false
|
86
|
+
end
|
87
|
+
|
88
|
+
def convert_aliased_col_to_real_col(col_name)
|
89
|
+
if respond_to?(:model) and model.respond_to?(:aliases) and model.aliases
|
90
|
+
sym_name = col_name.to_s.downcase.to_sym
|
91
|
+
col_name = model.aliases[sym_name].to_s.upcase if model.aliases.include? sym_name
|
92
|
+
end
|
93
|
+
col_name
|
94
|
+
end
|
95
|
+
|
96
|
+
def convert_aliased_col_to_real_col_with_model(col_name, model)
|
97
|
+
if model.respond_to?(:aliases) and model.aliases
|
98
|
+
sym_name = col_name.to_s.downcase.to_sym
|
99
|
+
col_name = model.aliases[sym_name].to_s.upcase if model.aliases.include? sym_name
|
100
|
+
end
|
101
|
+
col_name
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fossil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.46
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Lardin, Daniel Sudol
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-04-
|
12
|
+
date: 2010-04-29 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -159,10 +159,12 @@ files:
|
|
159
159
|
- lib/sequel/fos_dates.rb
|
160
160
|
- lib/sequel/metaprogramming.rb
|
161
161
|
- lib/sequel/model_patch.rb
|
162
|
+
- lib/sequel/mysql_pervasive_adapter.rb
|
162
163
|
- lib/sequel/pervasive_adapter.rb
|
163
164
|
- lib/sequel/serializer/json_serializer.rb
|
164
165
|
- lib/sequel/serializer/serializer.rb
|
165
166
|
- lib/sequel/serializer/xml_serializer.rb
|
167
|
+
- lib/sequel/sqlite_pervasive_adapter.rb
|
166
168
|
- lib/serial_number.rb
|
167
169
|
- spec/be_model_with_values_matcher.rb
|
168
170
|
- spec/be_model_with_values_matcher_spec.rb
|