Skip to content

Commit b3d6bd6

Browse files
committed
expose isView on DataTable
1 parent e69cb63 commit b3d6bd6

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

Diff for: README.md

+6
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,20 @@ object ${table.scalaName} {
217217
#{ val primaryKeyColumns = table.columns.filter(_.db.isPartOfPrimaryKey)}#
218218
type Id = ${if (primaryKeyColumns.isEmpty) "Null" else primaryKeyColumns.map(_.scalaType).mkString("(", ", ", ")")}
219219

220+
#if (!table.isView)
220221
case class Creator(
221222
#for (column <- table.columns if !column.db.isGenerated && !column.db.hasDefaultValue && !column.db.isAutoIncremented)
222223
${column.scalaName}: ${column.scalaType},
223224
#end
224225
)
226+
#end
225227
}
226228

229+
#if (table.isView)
230+
val ${table.scalaName}Repo = ImmutableRepo[${table.scalaName}, ${table.scalaName}.Id]
231+
#else
227232
val ${table.scalaName}Repo = Repo[${table.scalaName}.Creator, ${table.scalaName}, ${table.scalaName}.Id]
233+
#end
228234

229235
#end
230236
```

Diff for: codegen/src/main/scala/dbcodegen/DataSchema.scala

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ case class DataColumn(
1313
case class DataTable(
1414
name: String,
1515
columns: Seq[DataColumn],
16+
isView: Boolean,
1617
db: Table,
1718
) {
1819
def scalaName = NameFormat.sanitizeScalaName(NameFormat.toPascalCase(name))

Diff for: codegen/src/main/scala/dbcodegen/SchemaConverter.scala

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ object SchemaConverter {
3737
val dataTable = DataTable(
3838
table.getName,
3939
columns.toSeq,
40+
isView = table.isInstanceOf[View],
4041
table,
4142
)
4243

0 commit comments

Comments
 (0)