The main focus of this PR is to introduce typesafe default value annotations for table model specs that replace the now-removed @ColumnSpec(defaultValue = "?"). There are annotations for each primitive type (@DefaultLong, @DefaultString, etc.), as well as an explicit @DefaultNull and @DefaultExpression for specifying defaults as SQL expressions (in particular adding support for the special cases like CURRENT_TIMESTAMP). In addition to the annotations themselves only accepting a value of the correct type, we also perform validation confirming that only the expected type is used when defining a column default (i.e. we can log an error if a long column is annotated with @DefaultString).
This PR also removes the @ColumnSpec(name = "colName") field in favor of a dedicated @ColumnName("colName") annotation. This is the first step in a larger effort to break apart the different kinds of column definition components into their own annotations, rather than having a single monolithic annotation like ColumnSpec that does too many different things. Currently, ColumnSpec still exists only for the constraints field, but I expect that to also be replaced by a dedicated annotation in a future change. Update: I realized I could finish this part off by simply renaming ColumnSpec, so I did. @ColumnSpec is now @ConstraintSql, which accepts a single SQL string argument to be appended to the column constraints.
The main focus of this PR is to introduce typesafe default value annotations for table model specs that replace the now-removed
@ColumnSpec(defaultValue = "?")
. There are annotations for each primitive type (@DefaultLong
,@DefaultString
, etc.), as well as an explicit@DefaultNull
and@DefaultExpression
for specifying defaults as SQL expressions (in particular adding support for the special cases likeCURRENT_TIMESTAMP
). In addition to the annotations themselves only accepting a value of the correct type, we also perform validation confirming that only the expected type is used when defining a column default (i.e. we can log an error if a long column is annotated with@DefaultString
).This PR also removes the
@ColumnSpec(name = "colName")
field in favor of a dedicated@ColumnName("colName")
annotation. This is the first step in a larger effort to break apart the different kinds of column definition components into their own annotations, rather than having a single monolithic annotation likeColumnSpec
that does too many different things.Currently,Update: I realized I could finish this part off by simply renamingColumnSpec
still exists only for theconstraints
field, but I expect that to also be replaced by a dedicated annotation in a future change.ColumnSpec
, so I did.@ColumnSpec
is now@ConstraintSql
, which accepts a single SQL string argument to be appended to the column constraints.