租户字段冲突

Blade 未结 1 103
shark
shark 剑童 2025-05-29 12:09

一、该问题的重现步骤是什么?

1. 我自己开发了一些业务模块。自己的业务表中有tenant_id字段,与blade中的tenant_id字段名冲突。导致自己的业务sql查询语句在执行中被加入了AND tenant_id = '000000'

2. 

3.


二、你期待的结果是什么?实际看到的又是什么?

能否通过配置的方式处理字段冲突?

三、你正在使用的是什么产品,什么版本?在什么操作系统上?


四、请提供详细的错误堆栈信息,这很重要。

original SQL: select a.*,

               b.group_key   as groupKey,

               b.create_time as authTime,

               c.all_quota   as allQuota,

               c.daily_quota as dailyQuota

        from api_group a

                 left join (select * from api_group_tenant where tenant_id = ?) b on a.id = b.api_group_id

                 left join (select *

                            from tenant_quota_control

                            where tenant_id = ?

                              and control_type = 2

                              and is_del = 0) c

                           on b.b.id = c.control_target

        where a.is_del = 0

          and a.id in (select distinct(api_group_id) from api_group_tenant where tenant_id = ?)

        order by a.update_time desc

SQL to parse, SQL: select a.*,

               b.group_key   as groupKey,

               b.create_time as authTime,

               c.all_quota   as allQuota,

               c.daily_quota as dailyQuota

        from api_group a

                 left join (select * from api_group_tenant where tenant_id = ?) b on a.id = b.api_group_id

                 left join (select *

                            from tenant_quota_control

                            where tenant_id = ?

                              and control_type = 2

                              and is_del = 0) c

                           on b.b.id = c.control_target

        where a.is_del = 0

          and a.id in (select distinct(api_group_id) from api_group_tenant where tenant_id = ?)

        order by a.update_time desc

parse the finished SQL: SELECT a.*, b.group_key AS groupKey, b.create_time AS authTime, c.all_quota AS allQuota, c.daily_quota AS dailyQuota FROM api_group a LEFT JOIN (SELECT * FROM api_group_tenant WHERE tenant_id = ? AND tenant_id = '000000') b ON a.id = b.api_group_id LEFT JOIN (SELECT * FROM tenant_quota_control WHERE tenant_id = ? AND control_type = 2 AND is_del = 0 AND tenant_id = '000000') c ON b.b.id = c.control_target WHERE a.is_del = 0 AND a.id IN (SELECT DISTINCT (api_group_id) FROM api_group_tenant WHERE tenant_id = ? AND tenant_id = '000000') ORDER BY a.update_time DESC

JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@43b2ac8] will not be managed by Spring

==>  Preparing: SELECT a.*, b.group_key AS groupKey, b.create_time AS authTime, c.all_quota AS allQuota, c.daily_quota AS dailyQuota FROM api_group a LEFT JOIN (SELECT * FROM api_group_tenant WHERE tenant_id = ? AND tenant_id = '000000') b ON a.id = b.api_group_id LEFT JOIN (SELECT * FROM tenant_quota_control WHERE tenant_id = ? AND control_type = 2 AND is_del = 0 AND tenant_id = '000000') c ON b.b.id = c.control_target WHERE a.is_del = 0 AND a.id IN (SELECT DISTINCT (api_group_id) FROM api_group_tenant WHERE tenant_id = ? AND tenant_id = '000000') ORDER BY a.update_time DESC

==> Parameters: 8230944c275d41d2913bb9ca74872d46(String), 8230944c275d41d2913bb9ca74872d46(String), 8230944c275d41d2913bb9ca74872d46(String)

<==      Total: 0

五、若有更多详细信息,请在下面提供。

1条回答
  • 2025-05-29 12:54

    用@TenantIgnore注解放到controller或者service,就不会开起默认的租户插件功能了

    作者追问:2025-05-29 13:38

    @TenantIgnore注解无论加载controller还是service上,我自己的业务查询语句依然会被加上AND tenant_id = '000000'

    作者追问:2025-05-29 13:48

    我自己的业务中也有租户,和blade的租户功能没有交集,只是恰好数据库表字段tenant_id冲突。

    0 讨论(0)
代码语言
提交回复