-
-
Notifications
You must be signed in to change notification settings - Fork 232
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
Unexpected Data Truncation in CTE with Type Casting During Bulk Update #1093
Comments
If you want, you can disable explict casting by turn off With version >= v1.2.7, we add new function WithoutFeature |
@j2gg0s Is there a solution for handling such cases where only specific columns should be cast while others should not? For example, VARCHAR(N) columns would encounter the truncation issue if cast, so I want to avoid casting them. However, UUID columns must be cast; otherwise, they result in an error. |
If we only check a subset of type conversions, what criteria should we use to decide which subset to select? If we check all possible type conversions, is it necessary? The logic may become overly complex and repetitive, as the database already returns errors for most invalid cases. The two points above are not meant as challenges but rather as considerations that need to be weighed. |
Hmm, let me think about it for a bit. |
Relate #503 |
Would constructing an Append function for UUIDs be a better option? Are there any other similar data types that must also be converted? |
I am not sure a good decision because I’m not yet fully familiar with the design of this project... I think the goal here is to determine whether type casting is necessary. It depends on the column type and the database.
I’m sorry, I’m not very knowledgeable about databases… (The only example I could think of was UUID.) |
Hello,
I have encountered an issue with data truncation caused by type casting for a bulk update with CTEs. Below is a minimal reproducible example and the SQL query generated by the ORM (this code is in
internal/dbtest/pg_test.go
):generated sql:
The issue occurs because of the type casting in the VALUES clause ('abcd'::varchar(3)), which results in data truncation ('abcd' becomes 'abc'). This behavior seems problematic for the following reasons:
Could the ORM be enhanced to either:
Thank you for your time and consideration. Let me know if you need any further details or clarifications.
The text was updated successfully, but these errors were encountered: