Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View gist:6987484
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
# AR & Sequel
User.where(name: "Tom")
User.where("name = :name", name: "Tom")
User.where("name = ? OR email = ?", "Tom", "jack@jack.com")
User.where("users.name = ?", "Tom")
 
# AR-only
User.where(users: { name: "Tom" })
# Sequel-only
User.where(users__name: "Tom")
User.where(Sequel.lit('users.name') => "Tom")
 
# Sequel alternative option for "name = ? OR email = ?"
User.where(Sequel.expr(name: "Tom") | Sequel.expr(email: "jack@jack.com"))
# Sequel alternative option for "name = ? OR email != ?"
User.where(Sequel.expr(name: "Tom") | Sequel.~(email: "jack@jack.com"))
 
# AR-only
User.select("SUM(id)").first
# Sequel-only
User.select(Sequel.function(:sum, :id)).first
User.select(Sequel.lit("SUM(id)")).first
 
# AR-only (4.x)
User.where.not(name: "Tom")
# Sequel-only
User.exclude(name: "Tom")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.