-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
584 additions
and
95 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package io.github.klahap.pgen.model.sql | ||
|
||
import io.github.klahap.pgen.util.kotlinKeywords | ||
import io.github.klahap.pgen.util.makeDifferent | ||
import io.github.klahap.pgen.util.toCamelCase | ||
import kotlinx.serialization.Serializable | ||
|
||
|
||
@Serializable | ||
data class Statement( | ||
val name: SqlStatementName, | ||
val cardinality: Cardinality, | ||
val variables: List<VariableName>, | ||
val variableTypes: Map<VariableName, Table.Column.Type>, | ||
val columns: List<Table.Column>, | ||
val sql: String, | ||
) { | ||
@JvmInline | ||
@Serializable | ||
value class VariableName(val name: String) : Comparable<VariableName> { | ||
val pretty get() = name.toCamelCase(capitalized = false) | ||
.makeDifferent(kotlinKeywords + setOf("coroutineContext", "db")) | ||
override fun compareTo(other: VariableName): Int = name.compareTo(other.name) | ||
} | ||
|
||
data class Raw( | ||
val name: String, | ||
val cardinality: Cardinality, | ||
val allVariables: List<VariableName>, | ||
val uniqueSortedVariables: List<VariableName>, | ||
val nonNullColumns: Set<String>, | ||
val sql: String, | ||
val preparedPsql: String, | ||
val preparedSql: String, | ||
) | ||
|
||
@Serializable | ||
enum class Cardinality { | ||
ONE, | ||
MANY, | ||
} | ||
} |
Oops, something went wrong.