-
Notifications
You must be signed in to change notification settings - Fork 4
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
Refactor/2024 10 renewal schema #329
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
💪 enhancement
Functional enhancement
project:benchmark
Addition and modification of functionality to Benchmark projects
project:codegen
Addition and modification of functionality to CodeGen projects
project:queryBuilder
Addition and modification of functionality to Query Builder projects
project:schema
Addition and modification of functionality to Schema projects
🔧 refactor
Refactoring
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implementation Details
This pull request includes significant functionality improvements and enhancements. Please see below for details.
Enhancement
Adding Column Annotation
Table generation using Deriving used the property name as it is as the column name.
The formatting of the column names could be adjusted by implicitly passing Naming.
However, this alone could not address all cases. For example, the following column names cannot be used in the previous implementation.
Naming supports only certain formats (CAMEL, PASCAL, and SNAKE cases) and does not support column names that are all uppercase or only uppercase in certain parts of the column name.
Such cases can be resolved by using column annotations.
The overall formatting is done by Naming, and changes to only specific columns can be made using this annotation, which allows for flexible customization of column names.
Support for INSERT SELECT/JOIN
There are two ways to pass values in an INSERT statement: by VALUES or by using a SELECT statement or JOIN.
This modification supports both syntaxes.
The same can be defined for using the records resulting from a JOIN.
Breaking Change
Change column refinement method
So far, column refinement has simply grouped the columns used as Tuple.
cityTable.select(city => (city.id, city.name))
However, there was a problem with this. Column is a type with a single type parameter. Until Scala2, there was a limit to the number of Tuples that could be passed. Scala 2 had a limit on the number of Tuples, so it was necessary to create a boilerplate or something that could handle all the number of Tuples.
In this case, dynamic Tuples are treated as Tuples or Tuple.Map, so if you wanted to access a Column type, you had to cast the type using
asInstanceOf
because its type can only be treated as a Tuple.Casting the type would of course lose its type safety and complicate the code.
We decided to adopt twiddles, one of the same TypeLevel projects, to solve this problem.
Columns can be more easily composited by using twiddles.
Composition itself is implementor-friendly because it can be done using
*:
, and this eliminates the need for unsafe typecasting since the internal code can just use Column[T] instead of Tuple.Twiddles also make it easy to convert the composite result to another type.
Change from Table to TableQuery
Until now, the same Table type has been used to construct queries using the Table type and the Table type with Table information from the model.
Because the same type was used to represent two things, it was easy to implement incorrectly.
Development tools such as IDEs could cause no small amount of confusion to implementers because they complement all available APIs.
To solve this problem, we created a new type called TableQuery and separated the implementation of query construction.
Changes to Insert
The Insert statement is similarly modified so that columns are composited and inserted columns are specified.
Changes to Update
Previously, the Update Statement had to be set up one by one for each column to be updated. This implementation is convenient when you want to update a few columns individually, but it is very cumbersome to write
set
for each additional column you want to update.With this update, columns can now be combined, allowing multiple columns to be specified together for update processing.
With this update, columns can now be combined, allowing multiple columns to be specified together for update processing. It is still possible to update only specific columns using
set
. In addition, sinceset
can be used to set conditions for updating, it is possible to create a query that updates additional columns only when the conditions are positive.Changes to Join
Previously, table joins were constructed by setting the join condition as the second argument.
From this change, the conditions for joining tables must be set via the
on
API. This change is the result of an internal implementation change.Pull Request Checklist
References