Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【where条件中有函数和比较运算】 #742

Open
CarsonYue opened this issue Jul 22, 2024 · 2 comments
Open

【where条件中有函数和比较运算】 #742

CarsonYue opened this issue Jul 22, 2024 · 2 comments
Labels
Document 文档 文档 Enhancement 增强 增强功能、提高性能等

Comments

@CarsonYue
Copy link

Description

SELECT count(1)
FROM  report_contract_assessment_terms
WHERE GREATEST(contract_start_date, '2024-03-01') <= LEAST(contract_end_date, '2024-04-01');

以上sql应该如何实现?

@TommyLemon
Copy link
Collaborator

TommyLemon commented Jul 24, 2024

左侧的函数可以用 @key 映射,右侧的需要用 @raw
#627

{
    "Report_contract_assessment_terms": {
        "@column": "count(1)",
        "least_date<=": "LEAST(contract_end_date,'2024-04-01')", // 后端 DemoSQLConfig.RAW_MAP 配置下
        "@key": "least_date:GREATEST(contract_start_date,'2024-03-01')",
        "@raw": "least_date<="
    }
}

@TommyLemon TommyLemon added Enhancement 增强 增强功能、提高性能等 Document 文档 文档 labels Jul 24, 2024
@TommyLemon
Copy link
Collaborator

TommyLemon commented Jul 24, 2024

如果希望不配置 RAW_MAP,需要和 key{} , @column, @having 一样自动解析 SQL 函数/表达式,调用 parseSQLExpression
https://github.com/Tencent/APIJSON/blob/master/APIJSONORM/src/main/java/apijson/orm/AbstractSQLConfig.java#L2037-L2055

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Document 文档 文档 Enhancement 增强 增强功能、提高性能等
Projects
None yet
Development

No branches or pull requests

2 participants