Class: Arel::Visitors::SQLServer
- Inherits:
-
ToSql
- Object
- ToSql
- Arel::Visitors::SQLServer
show all
- Defined in:
- lib/composite_primary_keys/arel/sqlserver.rb
Instance Method Summary
collapse
Methods inherited from ToSql
#visit_CompositePrimaryKeys_CompositeKeys
Instance Method Details
#make_Fetch_Possible_And_Deterministic(o) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/composite_primary_keys/arel/sqlserver.rb', line 4
def make_Fetch_Possible_And_Deterministic o
return if o.limit.nil? && o.offset.nil?
t = table_From_Statement o
pk = primary_Key_From_Table t
return unless pk
if o.orders.empty?
o.orders = pk.map {|a_pk| a_pk.asc}
end
end
|
#primary_Key_From_Table(t) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/composite_primary_keys/arel/sqlserver.rb', line 17
def primary_Key_From_Table t
return unless t
column_name = @connection.schema_cache.primary_keys(t.name) ||
@connection.schema_cache.columns_hash(t.name).first.try(:second).try(:name)
case column_name
when Array
column_name.map do |name|
t[name]
end
when NilClass
nil
else
[t[column_name]]
end
end
|