GORM Playground Link

https://github.com/go-gorm/playground/pull/1

Description

  • Code:
query := db.Model("table_name").
            Select(
                "t.account_id",
                "t.account_name",
                "t.account_phone",
                "t.account_info",
                "t.channel_id",
                "t.create_time",
                "c.channel_name",
                "c.channel_status",
                "c.channel_base_info",
                "c.channel_extend_info",
                "? as name", req.Name,
            ).
            Joins(u.JoinBuilder(
                "join t_aio_channel_info as c",
                "c.account_id = t.account_id",
                "c.channel_status = ?",
            ), req.ChannelStatus)
  • Result:
[error]:Error 1054 (42S22): Unknown column 'xyz' in 'field list'[sql][5.061ms][rows:-]SELECT t_aio_account.account_id,1 as name,xyz FROM `t_aio_account` join t_aio_channel_info as c on c.account_id = t_aio_account.account_id and c.channel_status = 1 WHERE ***

Now: 1 as name,xyz

Should be: 'xyz' as name

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking