Class: Arel::Visitors::SQLServer
- Inherits:
-
ToSql
- Object
- ToSql
- Arel::Visitors::SQLServer
- Defined in:
- lib/sqlserver.rb
Instance Method Summary collapse
Instance Method Details
#primary_Key_From_Table(t) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/sqlserver.rb', line 30 def primary_Key_From_Table t return unless t # Use activerecord class, and get primary key from that rather than look in database arclass = t.send(:type_caster)&.send(:types)&.name&.constantize column_name = @connection.schema_cache.primary_keys(t.name) || arclass.primary_key || @connection.schema_cache.columns_hash(t.name).first.try(:second).try(:name) column_name ? t[column_name] : nil end |
#visit_Arel_Nodes_SelectStatement(o, collector) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/sqlserver.rb', line 10 def visit_Arel_Nodes_SelectStatement o, collector @select_statement = o distinct_One_As_One_Is_So_Not_Fetch o if o.with collector = visit o.with, collector collector << SPACE end collector = o.cores.inject(collector) { |c,x| visit_Arel_Nodes_SelectCore(x, c) } # Added this line to check for orders present if o.orders.present? collector = visit_Orders_And_Let_Fetch_Happen o, collector collector = visit_Make_Fetch_Happen o, collector end collector ensure @select_statement = nil end |