momomoto 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/momomoto/base.rb +1 -1
- data/lib/momomoto/datatype/base.rb +4 -0
- data/test/test_base.rb +5 -2
- data/test/test_datatype.rb +8 -0
- data/test/test_row.rb +13 -0
- metadata +17 -17
data/lib/momomoto/base.rb
CHANGED
@@ -147,7 +147,7 @@ module Momomoto
|
|
147
147
|
end
|
148
148
|
|
149
149
|
# defines row setter and getter in the module StandardMethods which
|
150
|
-
# is later included in the Row class
|
150
|
+
# is later included in the Row class
|
151
151
|
def define_row_accessors( method_module, table, columns = self.columns )
|
152
152
|
columns.each_with_index do | ( field_name, data_type ), index |
|
153
153
|
method_module.instance_eval do
|
@@ -34,6 +34,10 @@ module Momomoto
|
|
34
34
|
case value
|
35
35
|
when nil then
|
36
36
|
raise Error, "nil values not allowed for #{field_name}"
|
37
|
+
when :NULL then
|
38
|
+
field_name.to_s + ' IS NULL'
|
39
|
+
when :NOT_NULL then
|
40
|
+
field_name.to_s + ' IS NOT NULL'
|
37
41
|
when Array then
|
38
42
|
raise Error, "empty array conditions are not allowed for #{field_name}" if value.empty?
|
39
43
|
raise Error, "nil values not allowed in compile_rule for #{field_name}" if value.member?( nil )
|
data/test/test_base.rb
CHANGED
@@ -15,8 +15,11 @@ class TestBase < Test::Unit::TestCase
|
|
15
15
|
assert_equal( "AND", t2.logical_operator )
|
16
16
|
t1.logical_operator = "or"
|
17
17
|
assert_equal( "OR", t1.logical_operator )
|
18
|
-
|
19
|
-
|
18
|
+
assert( t1.instance_eval do compile_where(:person_id=>'1',:first_name=>'a') end.match( / OR / ) )
|
19
|
+
assert( t2.instance_eval do compile_where(:person_id=>'1',:first_name=>'a') end.match( / AND / ) )
|
20
|
+
assert_raise( Momomoto::Error ) do
|
21
|
+
t1.logical_operator = "chunky"
|
22
|
+
end
|
20
23
|
end
|
21
24
|
|
22
25
|
def test_compile_where
|
data/test/test_datatype.rb
CHANGED
@@ -39,6 +39,14 @@ class TestDatatype < Test::Unit::TestCase
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
def test_compile_rule_null
|
43
|
+
DATATYPES.each do | type |
|
44
|
+
t = type.new
|
45
|
+
assert_equal( "field_name IS NULL", t.compile_rule( :field_name, :NULL) )
|
46
|
+
assert_equal( "field_name IS NOT NULL", t.compile_rule( :field_name, :NOT_NULL) )
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
42
50
|
def test_operator_sign
|
43
51
|
DATATYPES.each do | type |
|
44
52
|
assert_equal( '<=', type.operator_sign( :le ) )
|
data/test/test_row.rb
CHANGED
@@ -43,6 +43,19 @@ class TestRow < Test::Unit::TestCase
|
|
43
43
|
assert_equal( a.person_id, a['person_id'])
|
44
44
|
end
|
45
45
|
|
46
|
+
def test_equal
|
47
|
+
a = Person.new
|
48
|
+
b = Person.new
|
49
|
+
assert( a == b )
|
50
|
+
assert( b == a )
|
51
|
+
a.person_id = 23
|
52
|
+
assert( a != b )
|
53
|
+
assert( b != a )
|
54
|
+
b.person_id = 23
|
55
|
+
assert( a == b )
|
56
|
+
assert( b == a )
|
57
|
+
end
|
58
|
+
|
46
59
|
def test_primary_key_setting
|
47
60
|
a = Person.select_single( nil, {:limit=>1})
|
48
61
|
assert_raise( Momomoto::Error ) do
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: momomoto
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
7
|
-
date: 2007-09-
|
6
|
+
version: 0.1.5
|
7
|
+
date: 2007-09-15 00:00:00 +02:00
|
8
8
|
summary: Momomoto is an object relational mapper for PostgreSQL.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -35,59 +35,59 @@ files:
|
|
35
35
|
- lib/momomoto/row.rb
|
36
36
|
- lib/momomoto/table.rb
|
37
37
|
- lib/momomoto/procedure.rb
|
38
|
-
- lib/momomoto/base.rb
|
39
38
|
- lib/momomoto/datatype.rb
|
39
|
+
- lib/momomoto/base.rb
|
40
40
|
- lib/momomoto/order.rb
|
41
41
|
- lib/momomoto/information_schema/table_constraints.rb
|
42
42
|
- lib/momomoto/information_schema/columns.rb
|
43
|
-
- lib/momomoto/information_schema/fetch_procedure_columns.rb
|
44
43
|
- lib/momomoto/information_schema/fetch_procedure_parameters.rb
|
44
|
+
- lib/momomoto/information_schema/fetch_procedure_columns.rb
|
45
45
|
- lib/momomoto/information_schema/routines.rb
|
46
46
|
- lib/momomoto/information_schema/key_column_usage.rb
|
47
|
-
- lib/momomoto/datatype/date.rb
|
48
47
|
- lib/momomoto/datatype/boolean.rb
|
48
|
+
- lib/momomoto/datatype/date.rb
|
49
49
|
- lib/momomoto/datatype/smallint.rb
|
50
50
|
- lib/momomoto/datatype/real.rb
|
51
51
|
- lib/momomoto/datatype/text.rb
|
52
52
|
- lib/momomoto/datatype/interval.rb
|
53
|
-
- lib/momomoto/datatype/time_without_time_zone.rb
|
54
|
-
- lib/momomoto/datatype/character_varying.rb
|
55
53
|
- lib/momomoto/datatype/character.rb
|
56
54
|
- lib/momomoto/datatype/integer.rb
|
55
|
+
- lib/momomoto/datatype/time_without_time_zone.rb
|
56
|
+
- lib/momomoto/datatype/character_varying.rb
|
57
57
|
- lib/momomoto/datatype/inet.rb
|
58
|
-
- lib/momomoto/datatype/timestamp_without_time_zone.rb
|
59
|
-
- lib/momomoto/datatype/time_with_time_zone.rb
|
60
58
|
- lib/momomoto/datatype/numeric.rb
|
61
59
|
- lib/momomoto/datatype/bytea.rb
|
62
|
-
- lib/momomoto/datatype/
|
60
|
+
- lib/momomoto/datatype/timestamp_without_time_zone.rb
|
61
|
+
- lib/momomoto/datatype/time_with_time_zone.rb
|
63
62
|
- lib/momomoto/datatype/base.rb
|
64
63
|
- lib/momomoto/datatype/bigint.rb
|
64
|
+
- lib/momomoto/datatype/timestamp_with_time_zone.rb
|
65
|
+
- sql/procedures.sql
|
65
66
|
- sql/types.sql
|
66
67
|
- sql/install.sql
|
67
|
-
-
|
68
|
+
- test/test_procedure.rb
|
68
69
|
- test/test_boolean.rb
|
69
70
|
- test/test_real.rb
|
70
71
|
- test/test_smallint.rb
|
71
72
|
- test/test_interval.rb
|
72
73
|
- test/test_text.rb
|
73
74
|
- test/test_table.rb
|
74
|
-
- test/
|
75
|
+
- test/test_numeric.rb
|
76
|
+
- test/test_inet.rb
|
75
77
|
- test/test_time_without_time_zone.rb
|
76
78
|
- test/test_character_varying.rb
|
77
79
|
- test/test_character.rb
|
78
80
|
- test/test_integer.rb
|
79
|
-
- test/
|
81
|
+
- test/test_datatype.rb
|
82
|
+
- test/test_row.rb
|
80
83
|
- test/test_timestamp_without_time_zone.rb
|
81
|
-
- test/test_numeric.rb
|
82
84
|
- test/test_time_with_time_zone.rb
|
83
85
|
- test/test_database.rb
|
84
86
|
- test/test_bytea.rb
|
85
87
|
- test/test_information_schema.rb
|
86
|
-
- test/test_row.rb
|
87
|
-
- test/test_timestamp_with_time_zone.rb
|
88
88
|
- test/test_base.rb
|
89
|
-
- test/test_datatype.rb
|
90
89
|
- test/test_bigint.rb
|
90
|
+
- test/test_timestamp_with_time_zone.rb
|
91
91
|
- test/test_date.rb
|
92
92
|
- test/test_functions.sql
|
93
93
|
- test/test.sql
|