arel 0.3.1 → 0.3.2
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/arel.rb +4 -3
- data/lib/arel/algebra.rb +1 -1
- data/lib/arel/algebra/attributes.rb +7 -0
- data/lib/arel/algebra/{attribute.rb → attributes/attribute.rb} +32 -0
- data/lib/arel/algebra/attributes/boolean.rb +21 -0
- data/lib/arel/algebra/attributes/decimal.rb +9 -0
- data/lib/arel/algebra/attributes/float.rb +9 -0
- data/lib/arel/algebra/attributes/integer.rb +10 -0
- data/lib/arel/algebra/attributes/string.rb +10 -0
- data/lib/arel/algebra/attributes/time.rb +6 -0
- data/lib/arel/algebra/predicates.rb +1 -0
- data/lib/arel/algebra/relations/operations/join.rb +4 -2
- data/lib/arel/algebra/relations/operations/order.rb +2 -1
- data/lib/arel/algebra/relations/operations/skip.rb +2 -1
- data/lib/arel/algebra/relations/operations/take.rb +2 -1
- data/lib/arel/algebra/relations/operations/where.rb +7 -6
- data/lib/arel/algebra/relations/relation.rb +2 -1
- data/lib/arel/algebra/relations/utilities/compound.rb +22 -2
- data/lib/arel/algebra/relations/utilities/externalization.rb +1 -1
- data/lib/arel/algebra/relations/utilities/nil.rb +2 -2
- data/lib/arel/engines/memory/predicates.rb +6 -0
- data/lib/arel/engines/memory/relations/array.rb +11 -4
- data/lib/arel/engines/memory/relations/compound.rb +1 -1
- data/lib/arel/engines/memory/relations/operations.rb +2 -2
- data/lib/arel/engines/sql.rb +1 -0
- data/lib/arel/engines/sql/attributes.rb +40 -0
- data/lib/arel/engines/sql/compilers/ibm_db_compiler.rb +0 -14
- data/lib/arel/engines/sql/predicates.rb +4 -0
- data/lib/arel/engines/sql/primitives.rb +0 -4
- data/lib/arel/engines/sql/relations/compiler.rb +5 -5
- data/lib/arel/engines/sql/relations/operations/join.rb +1 -1
- data/lib/arel/engines/sql/relations/relation.rb +1 -1
- data/lib/arel/engines/sql/relations/table.rb +6 -7
- data/lib/arel/engines/sql/relations/utilities/compound.rb +1 -1
- data/lib/arel/engines/sql/relations/utilities/nil.rb +1 -1
- data/lib/arel/session.rb +2 -2
- data/lib/arel/version.rb +3 -0
- data/spec/{arel/algebra → algebra}/unit/predicates/binary_spec.rb +0 -0
- data/spec/{arel/algebra → algebra}/unit/predicates/equality_spec.rb +0 -0
- data/spec/{arel/algebra → algebra}/unit/predicates/in_spec.rb +0 -0
- data/spec/{arel/algebra → algebra}/unit/primitives/attribute_spec.rb +0 -0
- data/spec/{arel/algebra → algebra}/unit/primitives/expression_spec.rb +0 -0
- data/spec/{arel/algebra → algebra}/unit/primitives/value_spec.rb +0 -0
- data/spec/{arel/algebra → algebra}/unit/relations/alias_spec.rb +0 -0
- data/spec/{arel/algebra → algebra}/unit/relations/delete_spec.rb +0 -0
- data/spec/{arel/algebra → algebra}/unit/relations/group_spec.rb +0 -0
- data/spec/{arel/algebra → algebra}/unit/relations/insert_spec.rb +0 -0
- data/spec/{arel/algebra → algebra}/unit/relations/join_spec.rb +0 -0
- data/spec/{arel/algebra → algebra}/unit/relations/order_spec.rb +0 -0
- data/spec/{arel/algebra → algebra}/unit/relations/project_spec.rb +0 -0
- data/spec/{arel/algebra → algebra}/unit/relations/relation_spec.rb +0 -0
- data/spec/{arel/algebra → algebra}/unit/relations/skip_spec.rb +0 -0
- data/spec/{arel/algebra → algebra}/unit/relations/table_spec.rb +0 -0
- data/spec/{arel/algebra → algebra}/unit/relations/take_spec.rb +0 -0
- data/spec/{arel/algebra → algebra}/unit/relations/update_spec.rb +0 -0
- data/spec/{arel/algebra → algebra}/unit/relations/where_spec.rb +1 -0
- data/spec/{arel/algebra → algebra}/unit/session/session_spec.rb +0 -0
- data/spec/attributes/boolean_spec.rb +57 -0
- data/spec/attributes/float_spec.rb +119 -0
- data/spec/attributes/integer_spec.rb +119 -0
- data/spec/attributes/string_spec.rb +43 -0
- data/spec/attributes/time_spec.rb +22 -0
- data/spec/{arel/engines → engines}/memory/integration/joins/cross_engine_spec.rb +1 -1
- data/spec/{arel/engines → engines}/memory/unit/relations/array_spec.rb +1 -1
- data/spec/{arel/engines → engines}/memory/unit/relations/insert_spec.rb +1 -1
- data/spec/{arel/engines → engines}/memory/unit/relations/join_spec.rb +1 -1
- data/spec/{arel/engines → engines}/memory/unit/relations/order_spec.rb +1 -1
- data/spec/{arel/engines → engines}/memory/unit/relations/project_spec.rb +1 -1
- data/spec/{arel/engines → engines}/memory/unit/relations/skip_spec.rb +1 -1
- data/spec/{arel/engines → engines}/memory/unit/relations/take_spec.rb +1 -1
- data/spec/{arel/engines → engines}/memory/unit/relations/where_spec.rb +1 -1
- data/spec/{arel/engines → engines}/sql/integration/joins/with_adjacency_spec.rb +0 -0
- data/spec/{arel/engines → engines}/sql/integration/joins/with_aggregations_spec.rb +0 -0
- data/spec/{arel/engines → engines}/sql/integration/joins/with_compounds_spec.rb +0 -0
- data/spec/{arel/engines → engines}/sql/unit/engine_spec.rb +0 -0
- data/spec/{arel/engines → engines}/sql/unit/predicates/binary_spec.rb +0 -0
- data/spec/{arel/engines → engines}/sql/unit/predicates/equality_spec.rb +0 -0
- data/spec/{arel/engines → engines}/sql/unit/predicates/in_spec.rb +0 -0
- data/spec/{arel/engines → engines}/sql/unit/predicates/predicates_spec.rb +0 -0
- data/spec/{arel/engines → engines}/sql/unit/primitives/attribute_spec.rb +0 -0
- data/spec/{arel/engines → engines}/sql/unit/primitives/expression_spec.rb +0 -0
- data/spec/{arel/engines → engines}/sql/unit/primitives/literal_spec.rb +0 -0
- data/spec/{arel/engines → engines}/sql/unit/primitives/value_spec.rb +0 -0
- data/spec/{arel/engines → engines}/sql/unit/relations/alias_spec.rb +0 -0
- data/spec/{arel/engines → engines}/sql/unit/relations/delete_spec.rb +0 -0
- data/spec/{arel/engines → engines}/sql/unit/relations/from_spec.rb +0 -0
- data/spec/{arel/engines → engines}/sql/unit/relations/group_spec.rb +0 -0
- data/spec/{arel/engines → engines}/sql/unit/relations/having_spec.rb +0 -0
- data/spec/{arel/engines → engines}/sql/unit/relations/insert_spec.rb +0 -0
- data/spec/{arel/engines → engines}/sql/unit/relations/join_spec.rb +0 -0
- data/spec/{arel/engines → engines}/sql/unit/relations/lock_spec.rb +0 -0
- data/spec/{arel/engines → engines}/sql/unit/relations/order_spec.rb +0 -0
- data/spec/{arel/engines → engines}/sql/unit/relations/project_spec.rb +0 -0
- data/spec/{arel/engines → engines}/sql/unit/relations/skip_spec.rb +0 -0
- data/spec/{arel/engines → engines}/sql/unit/relations/table_spec.rb +0 -0
- data/spec/{arel/engines → engines}/sql/unit/relations/take_spec.rb +0 -0
- data/spec/{arel/engines → engines}/sql/unit/relations/update_spec.rb +0 -0
- data/spec/{arel/engines → engines}/sql/unit/relations/where_spec.rb +0 -0
- data/spec/relations/join_spec.rb +40 -0
- data/spec/relations/relation_spec.rb +31 -0
- data/spec/shared/relation_spec.rb +142 -0
- data/spec/spec_helper.rb +17 -45
- data/spec/support/check.rb +6 -0
- data/spec/{connections → support/connections}/mysql_connection.rb +2 -4
- data/spec/{connections → support/connections}/oracle_connection.rb +3 -5
- data/spec/{connections → support/connections}/postgresql_connection.rb +2 -4
- data/spec/{connections → support/connections}/sqlite3_connection.rb +2 -4
- data/spec/support/guards.rb +28 -0
- data/spec/support/matchers.rb +4 -0
- data/spec/{matchers → support/matchers}/be_like.rb +1 -1
- data/spec/{matchers → support/matchers}/disambiguate_attributes.rb +1 -1
- data/spec/{matchers → support/matchers}/hash_the_same_as.rb +1 -1
- data/spec/support/matchers/have_rows.rb +18 -0
- data/spec/support/model.rb +58 -0
- data/spec/{schemas → support/schemas}/mysql_schema.rb +0 -0
- data/spec/{schemas → support/schemas}/oracle_schema.rb +0 -0
- data/spec/{schemas → support/schemas}/postgresql_schema.rb +0 -0
- data/spec/{schemas → support/schemas}/sqlite3_schema.rb +0 -0
- metadata +107 -163
- data/.gitignore +0 -6
- data/.gitmodules +0 -3
- data/Rakefile +0 -48
- data/Thorfile +0 -124
- data/arel.gemspec +0 -258
- data/doc/CONVENTIONS +0 -17
- data/doc/TODO +0 -118
- data/spec/doubles/hash.rb +0 -27
- data/spec/spec.opts +0 -3
data/doc/TODO
DELETED
@@ -1,118 +0,0 @@
|
|
1
|
-
todo:
|
2
|
-
- fix AR again
|
3
|
-
- blocks for joins
|
4
|
-
- fix sql insertions
|
5
|
-
- implement mnesia adapter
|
6
|
-
|
7
|
-
- CLEANUP!!!!!
|
8
|
-
- rename externalize to derived.
|
9
|
-
- deal with table tests in algebra
|
10
|
-
- fix grouping
|
11
|
-
- audit unit coverage of algebra
|
12
|
-
- data objects
|
13
|
-
- remove all explicit aliasing
|
14
|
-
- scoped writes
|
15
|
-
- refactor adapter pattern
|
16
|
-
- break out adapters into sep modules
|
17
|
-
- projection is by definition distincting?
|
18
|
-
- union/intersection
|
19
|
-
- cache expiry on write
|
20
|
-
- transactions
|
21
|
-
|
22
|
-
done:
|
23
|
-
- and/or w/ predicates
|
24
|
-
. Relation <=> Relation -> InnerJoinOperation
|
25
|
-
. Relation << Relation -> LeftOuterJoinOperation
|
26
|
-
. InnerJoinOperation.on(*Predicate) -> InnerJoinRelation
|
27
|
-
. LeftOuterJoinOperation.on(*Predicate) -> LeftOuterJoinRelation
|
28
|
-
. Relation[Symbol] -> Attribute
|
29
|
-
. Relation[Range] -> Relation
|
30
|
-
. Attribute == Attribute -> EqualityPredicate
|
31
|
-
. Attribute >= Attribute -> GreaterThanOrEqualToPredicate
|
32
|
-
. Relation.include?(Column) -> Predicate
|
33
|
-
. Relation.project(*Column) -> ProjectRelation
|
34
|
-
. Relation.select(*Predicate) -> SelectionRelation
|
35
|
-
. Relation.order(*Column) -> OrderRelation
|
36
|
-
. #to_sql
|
37
|
-
. Remove Builder
|
38
|
-
. Namespace
|
39
|
-
. Audit SqlAlchemy for missing features
|
40
|
-
- Generalized denormalizations on any aggregation (count, yes, but also max, min, average)
|
41
|
-
- Remove operator overloading of << and <=> for joins. Make it just foo.join(bar) and foo.outer_join(bar).
|
42
|
-
- Remove operator overloading of == for predicates. make it a.eq(b) (note lack of question mark).
|
43
|
-
- hookup more predicates (=, <=, =>)
|
44
|
-
- get some basic aggregations working: users.project(user[:points].max)
|
45
|
-
- Alias Table Names
|
46
|
-
- When joining with any sort of aggregation, it needs to be a nested select
|
47
|
-
- get a value select working: users.project(users[:name], addresses.select(addresses[:user_id] == users[:id]).project(addresses[:id].count))
|
48
|
-
- Session
|
49
|
-
- sublimate values to deal with the fact that they must be quoted per engine
|
50
|
-
- clean-up singleton monstrosity
|
51
|
-
- extract hashing module
|
52
|
-
- hash custom matcher
|
53
|
-
- make session engine stuff follow laws of demeter - currently doing some odd method chaining? rethink who is responsible for what
|
54
|
-
- session just calls execute, passing in a connection; by default it gets a connection from the relation.
|
55
|
-
- #formatter is now on value, attribute and relation; you must admit it's name is confusing given that e.g., relation already has a formatter (Sql::Relation) ... should it be called predicate formatter? operand1.to_sql(operand2.predicate) maybe prefer operand1.cast(operand2) or project or in light of
|
56
|
-
- renamed to #format: operand1.format(operand2)
|
57
|
-
- rename sql strategies
|
58
|
-
- need to_sql for ranges
|
59
|
-
- {:conditions=>{:id=>2..3}}
|
60
|
-
- nested orderings
|
61
|
-
- string passthrough
|
62
|
-
- conditions
|
63
|
-
- orderings
|
64
|
-
- relation inclusion when given an array (1,2,3,4) should quote the elements using the appropriate quoting formatter taken from the attribute
|
65
|
-
- descend on array, along with bind written in terms of it
|
66
|
-
- re-evaluate bind -- does bind belong inside the relation / predicate classes or in the factory methods?
|
67
|
-
- string passthrough:
|
68
|
-
:joins=>"INNER JOIN posts ON comments.post_id = posts.id"
|
69
|
-
- finish pending tests
|
70
|
-
- test relation, table reset
|
71
|
-
- test Value, in particular bind.
|
72
|
-
- test blank checks in relation.rb
|
73
|
-
- rename active_relation to arel
|
74
|
-
- mock out database
|
75
|
-
- fix complex joining cases:
|
76
|
-
- active record query adapter
|
77
|
-
- anonymous table names
|
78
|
-
- Explicitly model recursive structural decomposition / polymorphism
|
79
|
-
- Explicitly model the namer/externalizer using interpreter jargon
|
80
|
-
- All Sql Strategies should be accumulations with the top-level relation?
|
81
|
-
- instance methodify externalize
|
82
|
-
- test: find_attribute_given_attribute and all @attribute ||= everywhere and memoization of table class.
|
83
|
-
- rename select to where
|
84
|
-
- rename all ion classes
|
85
|
-
- joining with LIMIT is like aggregations!!
|
86
|
-
- blocks for non-joins
|
87
|
-
- expressions should be class-based, and joins too, anything _sql should be renamed
|
88
|
-
- implement in memory adapter
|
89
|
-
- clean up block_given stuff
|
90
|
-
- reorganize sql tests
|
91
|
-
- recursive memory operations
|
92
|
-
- reorganize memory tests
|
93
|
-
- result sets to attr correlation too
|
94
|
-
- implement joins in memory
|
95
|
-
- result sets should be array relations
|
96
|
-
- fix AR
|
97
|
-
- insertions for in memory
|
98
|
-
- cross-engine joins
|
99
|
-
|
100
|
-
icebox:
|
101
|
-
- #bind in Attribute and Expression should be doing a descend?
|
102
|
-
- try to make aggegration testing in join spec to be a bit more unit-like
|
103
|
-
- standardize quoting
|
104
|
-
- use strings everywhere, not symbols ?
|
105
|
-
- "unit" test sql strategies
|
106
|
-
- use real world examples, so they should be like a tutorial.
|
107
|
-
- rename the tion (Selection) classes so that words that don't end in tion don't seem inconsistent
|
108
|
-
- consider this code from has_many:
|
109
|
-
# replace the SELECT clause with COUNT(*), preserving any hints within /* ... */
|
110
|
-
@reflection.options[:counter_sql] = @reflection.options[:finder_sql].sub(/SELECT (\/\*.*?\*\/ )?(.*)\bFROM\b/im) { "SELECT #{$1}COUNT(*) FROM" }
|
111
|
-
- lock
|
112
|
-
- SELECT suchandsuch FOR UPDATE
|
113
|
-
- joins become subselects in writes:
|
114
|
-
users.delete().where(
|
115
|
-
addresses.c.user_id==
|
116
|
-
select([users.c.id]).
|
117
|
-
where(users.c.name=='jack')
|
118
|
-
)
|
data/spec/doubles/hash.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
class Hash
|
2
|
-
def ordered_array
|
3
|
-
to_a.sort { |(key1, value1), (key2, value2)| key1.hash <=> key2.hash }
|
4
|
-
end
|
5
|
-
|
6
|
-
undef :keys
|
7
|
-
def keys
|
8
|
-
ordered_array.collect(&:first)
|
9
|
-
end
|
10
|
-
|
11
|
-
undef :values
|
12
|
-
def values
|
13
|
-
ordered_array.collect { |_, v| v }
|
14
|
-
end
|
15
|
-
|
16
|
-
undef :each
|
17
|
-
def each(&block)
|
18
|
-
ordered_array.each(&block)
|
19
|
-
end
|
20
|
-
|
21
|
-
undef :shift
|
22
|
-
def shift
|
23
|
-
returning to_a.first do |k, v|
|
24
|
-
delete(k)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/spec/spec.opts
DELETED