flexirecord 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +8 -1
- data/lib/flexirecord.rb +9 -9
- metadata +2 -2
data/CHANGELOG
CHANGED
@@ -32,5 +32,12 @@
|
|
32
32
|
- >
|
33
33
|
Fixed a bug in the FlexiRecord::ListRecord module.
|
34
34
|
- >
|
35
|
-
'src_to_dst_attr' and 'dst_to_src_attr' arguments of
|
35
|
+
'src_to_dst_attr' and 'dst_to_src_attr' arguments of
|
36
|
+
FlexiRecord::Reference.new are now allowed to be nil.
|
37
|
+
|
38
|
+
- Release of version 0.0.5.
|
39
|
+
|
40
|
+
- 2007-02-16:
|
41
|
+
- >
|
42
|
+
SELECT DISTINCT has been replaced by SELECT (ALL).
|
36
43
|
|
data/lib/flexirecord.rb
CHANGED
@@ -358,7 +358,6 @@ module FlexiRecord
|
|
358
358
|
end
|
359
359
|
sql_snippet = sql_snippet.to_str
|
360
360
|
end
|
361
|
-
# TODO: Do SELECT DISTINCT perhaps? (breaks for now, as ORDER BY expressions must appear in select list)
|
362
361
|
destination_records = unless source_records.empty?
|
363
362
|
destination_class.sql(
|
364
363
|
'SELECT ' << FlexiRecord::DefaultTableAlias << '.* FROM (' <<
|
@@ -498,7 +497,7 @@ module FlexiRecord
|
|
498
497
|
return @flexirecord_preloaded[cache_key] = loader.call(self, arguments)
|
499
498
|
end
|
500
499
|
|
501
|
-
# Returns a RecordArray of re-selected objects. This can be used to re-sort records by the database, to do further filtering, or to reload all records at once.
|
500
|
+
# Returns a RecordArray of re-selected objects. This can be used to re-sort records by the database, to do further filtering, or to reload all records at once.
|
502
501
|
def reselect(sql_snippet=nil, *arguments)
|
503
502
|
unless self.empty?
|
504
503
|
@flexirecord_class.select_by_value_set(@flexirecord_class.primary_columns, self.collect { |record| @flexirecord_class.primary_columns.collect { |column| record.read(column) } }, sql_snippet, *arguments)
|
@@ -732,9 +731,9 @@ module FlexiRecord
|
|
732
731
|
end
|
733
732
|
end
|
734
733
|
|
735
|
-
# Wrapper for the 'sql' method including already a part of the SQL select command. Please see the source code to understand how this method works.
|
734
|
+
# Wrapper for the 'sql' method including already a part of the SQL select command. Please see the source code to understand how this method works.
|
736
735
|
def select(sql_snippet=nil, *arguments)
|
737
|
-
sql("SELECT
|
736
|
+
sql("SELECT #{FlexiRecord::DefaultTableAlias}.* FROM #{table} #{FlexiRecord::DefaultTableAlias}#{sql_snippet ? ' ' : ''}#{sql_snippet}", *arguments)
|
738
737
|
end
|
739
738
|
|
740
739
|
# Same as 'select', but returns only the first member of the Array, or nil.
|
@@ -742,7 +741,7 @@ module FlexiRecord
|
|
742
741
|
select(*arguments).first
|
743
742
|
end
|
744
743
|
|
745
|
-
# Executes an SQL query, selecting rows matching a given set of keys and values, optionally appending a given SQL snippet with parameters. Returns an Array of records.
|
744
|
+
# Executes an SQL query, selecting rows matching a given set of keys and values, optionally appending a given SQL snippet with parameters. Returns an Array of records.
|
746
745
|
def select_by_value_set(keys, set_of_values, sql_snippet=nil, *arguments)
|
747
746
|
flattened_values = set_of_values.to_ary.flatten
|
748
747
|
if flattened_values.empty?
|
@@ -750,14 +749,14 @@ module FlexiRecord
|
|
750
749
|
else
|
751
750
|
if sql_snippet
|
752
751
|
return sql(
|
753
|
-
'SELECT ' <<
|
752
|
+
'SELECT ' << FlexiRecord::DefaultTableAlias << '.* FROM (' <<
|
754
753
|
'SELECT * FROM ' << table << ' WHERE (' << keys.collect { |key| '"' << key << '"' }.join(', ') << ') ' << 'IN (' << set_of_values.collect { |values| '(' << values.collect { |value| '$' }.join(', ') << ')' }.join(', ') << ')' <<
|
755
754
|
') AS ' << FlexiRecord::DefaultTableAlias << ' ' << sql_snippet.to_s,
|
756
755
|
*(flattened_values + arguments)
|
757
756
|
)
|
758
757
|
else
|
759
758
|
return sql(
|
760
|
-
'SELECT
|
759
|
+
'SELECT * FROM ' << table << ' WHERE (' << keys.collect { |key| '"' << key << '"' }.join(', ') << ') ' << 'IN (' << set_of_values.collect { |values| '(' << values.collect { |value| '$' }.join(', ') << ')' }.join(', ') << ')',
|
761
760
|
*(flattened_values + arguments)
|
762
761
|
)
|
763
762
|
end
|
@@ -884,7 +883,7 @@ module FlexiRecord
|
|
884
883
|
nil
|
885
884
|
end
|
886
885
|
|
887
|
-
# Helper
|
886
|
+
# Helper method for dup and replace. Do not use directly.
|
888
887
|
def read_internal_state
|
889
888
|
return @data_hash.dup, @saved, @old_primary_key.dup
|
890
889
|
end
|
@@ -1121,6 +1120,7 @@ module FlexiRecord
|
|
1121
1120
|
end
|
1122
1121
|
end
|
1123
1122
|
|
1123
|
+
# TODO: write documentation
|
1124
1124
|
def destroy
|
1125
1125
|
if self.saved?
|
1126
1126
|
self.class.db_execute('DELETE FROM ' << self.class.table <<
|
@@ -1434,7 +1434,7 @@ module FlexiRecord
|
|
1434
1434
|
end
|
1435
1435
|
end
|
1436
1436
|
|
1437
|
-
#
|
1437
|
+
# TODO: write documentation
|
1438
1438
|
def close
|
1439
1439
|
@backend_connection.close
|
1440
1440
|
@backend_connection = nil
|
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: 0.0.
|
7
|
-
date: 2007-02-
|
6
|
+
version: 0.0.6
|
7
|
+
date: 2007-02-16 00:00:00 +00:00
|
8
8
|
summary: Object-Oriented Database Access Library
|
9
9
|
require_paths:
|
10
10
|
- lib/
|