select() with join() seems to lack a wildcard for on entire table and a partial second table request

28 views
Skip to first unread message

Ferenc Collins

unread,
Jun 15, 2019, 2:16:10 PM6/15/19
to lovefield-users
Hi,

I'm trying to do something like this:

db.select(db_cards.*,db_cache.thumbnail)
  .from(db_cards)
  .leftOuterJoin(db_cache,db_cache.id.eq(db_files.id))

...but it doesn't seem possible to use the wildcard "*".

I can only guess that I need to try

db.select(db_cards.field_1, db_cards.field2, db_cards.field3, [...etc...], db_cache.thumbnail)
  .from(db_cards)
  .leftOuterJoin(db_cache,db_cache.id.eq(db_files.id))

...which is possible but if I have 20+ fields in db_cards - (a) can I still rely on the mechanism to work correctly? and (b) might it have an impact on performance if too many fields are individually fetched?

Or have I missed something in the documentation?

Thanks

Demetrios Papadopoulos

unread,
Jun 17, 2019, 1:23:38 PM6/17/19
to lovefield-users
Hi.

select() eithert returns every column (when no arguments are passed), or returns explicitly the columns that have been requested. Can you just use select() here? This would solve your issue, with a minor caveat of having all of db_cache columns in the result, which you can ignore though.

Also, does the "wildcard" feature exist in SQL? Could you post the equivalent SQL query of what you are trying to project?

Ferenc Collins

unread,
Jun 18, 2019, 1:04:46 PM6/18/19
to lovefield-users
The equivalent in SQL would be:

SELECT db_cards.*, db_cache.thumbnail from db_cards
 left join db_cache on db_cache
.id=db_cards.id;


(My original example had a mistake in that I put db_files instead of db_cards - hope that didn't confuse - I couldn't edit it for some reason)

I don't want to use .select() because there it could potentially return hundreds of megabytes of blobs stored in db and I want to exclude the huge blobs, avoid a memory-related crash, and for it to be performant.


Arthur Hsu

unread,
Jun 18, 2019, 1:26:06 PM6/18/19
to lovefield-users
So far we don't have a good way to list all columns except writing them down one-by-one. Will consider adding that feature to the TypeScript port.
Reply all
Reply to author
Forward
0 new messages