camertron / scuttle-rb

A library for transforming raw SQL statements into ActiveRecord/Arel queries. Ruby wrapper and tests for scuttle-java.
86 stars 2 forks source link

[Feature Request] Support type casting #16

Open Looooong opened 2 years ago

Looooong commented 2 years ago

The following SQL:

SELECT CAST (posts.created_at as date) FROM posts

should be translated to:

Post.select(
  Arel::Nodes::NamedFunction.new('CAST', [Post.arel_table[:created_at].as('date')])
)
camertron commented 2 years ago

Hey @Looooong, thanks for filing this. Any interest in submitting a PR?