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.
A common problem with SQL is the high probability of having too many columns in the projection. This may be due to reckless usage of SELECT * or some refactoring which removes the need to select some of the projected columns, but the query was not adapted.
The design of the table depends on the entity it needs to store. If all the data belongs together, then 50 columns (or even 100) might be the correct thing to do. So long as the table is normalized, there is no rule of thumb regarding size, apart from database capabilities and the need to optimize.
For the columns in a table, there is a maximum limit of 1024 columns in a table. SQL Server does have a wide-table feature that allows a table to have up to 30,000 columns instead of 1024.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With