flexirecord 1.0.2 → 1.0.3
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/CHANGELOG +10 -1
- data/flexirecord-oldpg.rb.patch +7 -16
- data/lib/flexirecord.rb +32 -9
- metadata +2 -2
data/CHANGELOG
CHANGED
@@ -61,7 +61,16 @@
|
|
61
61
|
|
62
62
|
- 2007-03-08:
|
63
63
|
- >
|
64
|
-
Fixed a bug, which caused a runtime error, when reading negative numeric data from the database.
|
64
|
+
Fixed a bug, which caused a runtime error, when reading negative numeric data from the database.
|
65
65
|
|
66
66
|
- Release of version 1.0.2
|
67
67
|
|
68
|
+
- 2007-03-09:
|
69
|
+
- >
|
70
|
+
Bug in PostgreSQL 8.1 compatiblity patch, which occured when being used with triggers, was fixed.
|
71
|
+
- >
|
72
|
+
Added support for floats in addition to rationals/numerics.
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
data/flexirecord-oldpg.rb.patch
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
--- flexirecord.rb 2007-
|
2
|
-
+++ flexirecord-oldpg.rb 2007-
|
3
|
-
@@ -
|
1
|
+
--- flexirecord.rb 2007-03-08 21:01:55.000000000 +0000
|
2
|
+
+++ flexirecord-oldpg.rb 2007-03-09 15:25:31.000000000 +0000
|
3
|
+
@@ -652,7 +652,7 @@
|
4
4
|
primary_columns = []
|
5
5
|
db_query('SELECT ' <<
|
6
6
|
'"pg_attribute"."attname", ' <<
|
@@ -9,16 +9,7 @@
|
|
9
9
|
'FROM "pg_attribute" ' <<
|
10
10
|
'JOIN "pg_class" ON "pg_attribute"."attrelid" = "pg_class"."oid" ' <<
|
11
11
|
'JOIN "pg_namespace" ON "pg_class"."relnamespace" = "pg_namespace"."oid" ' <<
|
12
|
-
@@ -
|
13
|
-
)
|
14
|
-
end
|
15
|
-
|
16
|
-
- # Adds a ManyToOneReference to the class (by simply creating it). The first argument is the destination class, followed by arguments being passed to Reference.new.
|
17
|
-
+ # Adds a ManyToManyReference to the class (by simply creating it). The first argument is the destination class, followed by arguments being passed to Reference.new.
|
18
|
-
def add_many_to_one_reference(destination_class, *arguments)
|
19
|
-
return FlexiRecord::ManyToOneReference.new(
|
20
|
-
self, destination_class, *arguments
|
21
|
-
@@ -985,16 +985,14 @@
|
12
|
+
@@ -1074,16 +1074,14 @@
|
22
13
|
def save
|
23
14
|
synchronize do
|
24
15
|
used_columns = self.used_columns
|
@@ -37,7 +28,7 @@
|
|
37
28
|
*(
|
38
29
|
used_columns.collect { |column| read(column) } +
|
39
30
|
self.class.primary_columns.collect { |column| @old_primary_key[column] }
|
40
|
-
@@ -
|
31
|
+
@@ -1091,18 +1089,12 @@
|
41
32
|
)
|
42
33
|
else
|
43
34
|
if used_columns.empty?
|
@@ -59,7 +50,7 @@
|
|
59
50
|
*(
|
60
51
|
used_columns.collect { |column| read(column) }
|
61
52
|
)
|
62
|
-
@@ -
|
53
|
+
@@ -1110,10 +1102,9 @@
|
63
54
|
end
|
64
55
|
@saved = true
|
65
56
|
end
|
@@ -68,7 +59,7 @@
|
|
68
59
|
- self.set(column, primary_key.read(column))
|
69
60
|
- end
|
70
61
|
+ if self.class.primary_columns == ['id'] and self.id.nil?
|
71
|
-
+ primary_key = self.class.db_query1(
|
62
|
+
+ primary_key = self.class.db_query1(%Q{SELECT currval('#{self.class.schema_name ? "#{self.class.schema_name}.#{self.class.table_name}" : self.class.table_name}_id_seq') AS "id"})
|
72
63
|
+ self.id = primary_key.id
|
73
64
|
end
|
74
65
|
copy_primary_key
|
data/lib/flexirecord.rb
CHANGED
@@ -1265,20 +1265,33 @@ module FlexiRecord
|
|
1265
1265
|
# Executes an SQL query and returns an Array of objects of 'record_class' (which should be a sub-class of BaseRecord). The 'command_template' is an SQL statement with '$' placeholders to be replaced by the following 'command_arguments'.
|
1266
1266
|
def record_query(record_class, command_template, *command_arguments)
|
1267
1267
|
command = command_template.to_s.gsub(/\$([^0-9]|$)/) {
|
1268
|
+
rest = $1
|
1268
1269
|
if command_arguments.empty?
|
1269
1270
|
raise ArgumentError, "Too few arguments supplied for SQL command."
|
1270
1271
|
end
|
1271
1272
|
command_argument = command_arguments.shift
|
1272
|
-
if command_argument.kind_of?
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1273
|
+
if command_argument.kind_of? Float
|
1274
|
+
if command_argument.finite?
|
1275
|
+
PGconn.quote(command_argument)
|
1276
|
+
elsif command_argument.nan?
|
1277
|
+
"'NaN'"
|
1278
|
+
elsif command_argument < 0
|
1279
|
+
"'-Infinity'"
|
1280
|
+
else
|
1281
|
+
"'Infinity'"
|
1278
1282
|
end
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1283
|
+
else
|
1284
|
+
if command_argument.kind_of? Rational
|
1285
|
+
command_argument = command_argument.to_f
|
1286
|
+
elsif command_argument.kind_of? Time
|
1287
|
+
time_offset_hours = command_argument.utc_offset / 3600
|
1288
|
+
unless 3600 * time_offset_hours == command_argument.utc_offset
|
1289
|
+
raise "Time zone offset is not an integer amount of hours."
|
1290
|
+
end
|
1291
|
+
command_argument = "%s.%06i%+03i" % [command_argument.strftime("%Y-%m-%d %H:%M:%S"), command_argument.usec, time_offset_hours]
|
1292
|
+
end
|
1293
|
+
PGconn.quote(command_argument)
|
1294
|
+
end << rest
|
1282
1295
|
# argument = command_arguments.shift
|
1283
1296
|
# if argument.kind_of? FlexiRecord::SqlSnippet
|
1284
1297
|
# argument.to_s + $1
|
@@ -1319,6 +1332,16 @@ module FlexiRecord
|
|
1319
1332
|
else
|
1320
1333
|
$1.to_i
|
1321
1334
|
end
|
1335
|
+
elsif ["float4", "float8"].include? data_type
|
1336
|
+
if value_string =~ /^NaN$/i
|
1337
|
+
0.0 / 0.0
|
1338
|
+
elsif value_string =~ /^Infinity$/i
|
1339
|
+
1.0 / 0.0
|
1340
|
+
elsif value_string =~ /^-Infinity$/i
|
1341
|
+
-1.0 / 0.0
|
1342
|
+
else
|
1343
|
+
value_string.to_f
|
1344
|
+
end
|
1322
1345
|
elsif data_type == "date"
|
1323
1346
|
unless value_string =~ /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/
|
1324
1347
|
raise "Unexpected format for date from database."
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: flexirecord
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.0.
|
7
|
-
date: 2007-03-
|
6
|
+
version: 1.0.3
|
7
|
+
date: 2007-03-10 00:00:00 +00:00
|
8
8
|
summary: Object-Oriented Database Access Library (ORM layer)
|
9
9
|
require_paths:
|
10
10
|
- lib/
|