sqlgoormsqlboiler

SQLBoiler get table name for Join


I am trying to follow the examples in sqlboiler (https://github.com/volatiletech/sqlboiler). But, I can't find a way to get the table name used in the Inner join query.

users, err := models.Users(
  Select("id", "name"),
  InnerJoin("credit_cards c on c.user_id = users.id"),
  Where("age > ?", 30),
  AndIn("c.kind in ?", "visa", "mastercard"),
  Or("email like ?", `%aol.com%`),
  GroupBy("id", "name"),
  Having("count(c.id) > ?", 2),
  Limit(5),
  Offset(6),
).All(ctx, db)

In this example, if, instead of hard-coding the name (credit_cards), I could provide the table name, it'd be great.

Thanks!


Solution

  • The table names are in the TableNames struct, which is in the file boil_table_names.go

    So, I think it would be something like this models.TableNames.CreditCards