Skip to content

Commit 4be5c99

Browse files
committed
Fix repositories not using type wrappers
1 parent 9abe9f2 commit 4be5c99

16 files changed

+72
-66
lines changed

docs/classes/Generator.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

docs/interfaces/CommonCustomTypesOptions.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

docs/interfaces/CommonOptions.html

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

docs/interfaces/CommonPrimaryKeyOptions.html

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.

docs/interfaces/CommonTypeAdapterOptions.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

docs/interfaces/ExportOptions.html

Lines changed: 8 additions & 8 deletions
Large diffs are not rendered by default.

docs/interfaces/FieldMapping.html

Lines changed: 5 additions & 5 deletions
Large diffs are not rendered by default.

docs/interfaces/GeneratedField.html

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.

docs/interfaces/GeneratedFieldType.html

Lines changed: 5 additions & 5 deletions
Large diffs are not rendered by default.

docs/interfaces/GeneratorOpts.html

Lines changed: 16 additions & 16 deletions
Large diffs are not rendered by default.

docs/interfaces/ImportedItem.html

Lines changed: 5 additions & 5 deletions
Large diffs are not rendered by default.

docs/interfaces/TableInclusion.html

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.

docs/types/StrOrRegExp.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/variables/fieldMappings.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/generator.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -770,9 +770,12 @@ export class Generator {
770770
tableName: string,
771771
tableKind: TableKind,
772772
mapperClassName: string,
773-
imports: ImportTmplInput[]
773+
imports: ImportTmplInput[],
774+
774775
) {
775-
const rowTypes = this.opts.export?.rowTypes
776+
const isExported = this.opts.export?.rowTypes;
777+
const hasRepo = this.opts.export?.crudRepository;
778+
const rowTypes = (isExported || hasRepo)
776779
? ({} as any)
777780
: false;
778781
if (rowTypes !== false) {
@@ -781,17 +784,20 @@ export class Generator {
781784
`SelectedRow<${mapperClassName}>`,
782785
imports
783786
);
787+
rowTypes.selected.isExported = isExported;
784788
if (tableKind !== "View") {
785789
rowTypes.insertable = this.getWrappedTypeInput(
786790
this.getInsertableRowTypeName(tableName),
787791
`InsertableRow<${mapperClassName}>`,
788792
imports
789793
);
794+
rowTypes.insertable.isExported = isExported;
790795
rowTypes.updatable = this.getWrappedTypeInput(
791796
this.getUpdatableRowTypeName(tableName),
792797
`UpdatableRow<${mapperClassName}>`,
793798
imports
794799
);
800+
rowTypes.updatable.isExported = isExported;
795801
}
796802
}
797803
return rowTypes

src/template.ts.hbs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export class {{repo.className}} {
162162
{{/if}}
163163
{{#if repo.methods.insertOne}}
164164

165-
{{repo.methods.insertOne}}(row: InsertableRow<{{className}}>, conn = this.getConnection()) {
165+
{{repo.methods.insertOne}}(row: {{rowTypes.insertable.name}}, conn = this.getConnection()) {
166166
return this.insert(conn)
167167
.set(row)
168168
.returning(this.tableCols)
@@ -171,7 +171,7 @@ export class {{repo.className}} {
171171
{{/if}}
172172
{{#if repo.methods.insertMany}}
173173

174-
{{repo.methods.insertMany}}(rows: InsertableRow<{{className}}>[], conn = this.getConnection()) {
174+
{{repo.methods.insertMany}}(rows: {{rowTypes.insertable.name}}[], conn = this.getConnection()) {
175175
return this.insert(conn)
176176
.values(rows)
177177
.returning(this.tableCols)
@@ -186,7 +186,7 @@ export class {{repo.className}} {
186186
{{/if}}
187187
{{#if repo.methods.updateOne}}
188188

189-
{{repo.methods.updateOne}}({{pkField.name}}: {{className}}Pk, update: UpdatableRow<{{className}}>, conn = this.getConnection()) {
189+
{{repo.methods.updateOne}}({{pkField.name}}: {{className}}Pk, update: {{rowTypes.updatable.name}}, conn = this.getConnection()) {
190190
return this.update(conn)
191191
.set(update)
192192
.where(this.table.{{pkField.name}}.equals({{pkField.name}}))
@@ -196,7 +196,7 @@ export class {{repo.className}} {
196196
{{/if}}
197197
{{#if repo.methods.updateMany}}
198198

199-
{{repo.methods.updateMany}}({{pkField.name}}List: {{className}}Pk[], update: UpdatableRow<{{className}}>, conn = this.getConnection()) {
199+
{{repo.methods.updateMany}}({{pkField.name}}List: {{className}}Pk[], update: {{rowTypes.updatable.name}}, conn = this.getConnection()) {
200200
return this.update(conn)
201201
.set(update)
202202
.where(this.table.{{pkField.name}}.in({{pkField.name}}List))

0 commit comments

Comments
 (0)