[jira] [Commented] (TORQUE-373) DEFAULT value generated for non supporting sql-types

"Max Philipp Wriedt (Jira)" <[email protected]> Mon, 20 Jul 2026 00:00:00 +0000 (UTC)
Newsgroups gmane.comp.jakarta.turbine.torque.devel
Message-ID <[email protected]>
    [ https://issues.apache.org/jira/browse/TORQUE-373?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18097468#comment-18097468 ] 

Max Philipp Wriedt commented on TORQUE-373:
-------------------------------------------

[~gk] sounds good, and it fits the class anyway. {{hasSize}} and {{hasScale}} sit right above that spot in {{SQLModelTransformer.getDdlSql}} and have the same shape.

One thing I got wrong in the description: it isn't only LONGVARCHAR. In {{PlatformMysqlImpl}} six schema types end up on a type that can't take a default, namely LONGVARCHAR (MEDIUMTEXT), CLOB (LONGTEXT), BINARY (BLOB), VARBINARY (MEDIUMBLOB), and LONGVARBINARY and BLOB (both LONGBLOB). I just happened to run into the LONGVARCHAR one.

{{hasSize}} in the same class already maintains exactly that list:

{code:java}
return !(Arrays.asList("MEDIUMTEXT", "LONGTEXT", "BLOB", "MEDIUMBLOB", "LONGBLOB")
        .contains(sqlType));
{code}

so hasDefault can reuse it, probably as a shared constant rather than keeping the same list twice.

I'll log a warning when a default is dropped instead of removing it silently, so it doesn't disappear from the generated schema without a trace. (Newer MySQL and MariaDB do accept defaults on TEXT/BLOB, MySQL only as a parenthesized expression, but we don't distinguish platform versions at all, so that would be its own issue.)


> DEFAULT value generated for non supporting sql-types
> ----------------------------------------------------
>
>                 Key: TORQUE-373
>                 URL: https://issues.apache.org/jira/browse/TORQUE-373
>             Project: Torque
>          Issue Type: Task
>          Components: Templates
>    Affects Versions: 6.0, 7.0
>            Reporter: Max Philipp Wriedt
>            Assignee: Max Philipp Wriedt
>            Priority: Major
>
> When defining a column as LONGVARCHAR with a default value the SQL generated contains a "DEFAULT" which is invalid for the mapped "MEDIUMTEXT" in MySQL/MariaDB. (but might be ignored/warning-only based on the executor of the SQL-schema).
> I've started working on a fix, but I'm indifferent, whether this is a special case for MySQL or if we should add a "hasDefault" at the Platform interface.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)