6

It seems like the default select for Sequel is "select *", which causes all kinds of problems when you add some joins. At the very least you end up with the wrong ids in your objects (because there will then be more than one "id" column returned). Doing something like

.select("people.*")

would seem to work, but that treats the string passed in as a column and quotes it. So far I've had to revert back to bare SQL to solve this, but I know there has to be a better way.

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Phil Kulak
  • 6,960
  • 8
  • 45
  • 50

1 Answers1

5

The default behavior for Sequel is to select all columns, but it is easy to override. If you want to select only all columns from a single table:

.select(:people.*)

If you want to use a literal SQL string:

.select('people.*'.lit)

Jeremy Evans
  • 11,959
  • 27
  • 26
  • 8
    These syntaxes aren't working for me, as of Sequel 4.10. `:people.*` complains `undefined method * for :people:Symbol`, and `'people.*'.lit` complains `undefined method lit for "people.*":String`. `:'people.*'` just ends up searching for `"people.*"`. `.select_all(:people)` does the trick, though. – womble May 25 '14 at 00:20
  • `select_all` also accepts multiple tables. If you want all columns from a couple tables and a specific column from a third table, use `select_all(:tbl1, :tbl2).select_more(:tbl3__col)` – Kelvin Jun 23 '15 at 16:41
  • 2
    `'people.*'.lit` is now `Sequel.lit('people.*')` – Kelvin Jun 23 '15 at 16:42