Skip to content

Commit afcd401

Browse files
chore: wip
1 parent cd4ccd1 commit afcd401

File tree

17 files changed

+27
-25
lines changed

17 files changed

+27
-25
lines changed

storage/framework/core/orm/src/generate.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export async function generateModelString(
4545
let mittDeleteStatement = ''
4646
let mittDeleteStaticFindStatement = ''
4747
let mittDeleteFindStatement = ''
48+
let privateSoftDeletes = ''
4849

4950
const relations = await getRelations(model, modelName)
5051

@@ -68,6 +69,7 @@ export async function generateModelString(
6869
}
6970

7071
if (useSoftDeletes) {
72+
privateSoftDeletes = `private softDeletes = false`
7173
instanceSoftDeleteStatements += `if (instance.softDeletes) {
7274
query = query.where('deleted_at', 'is', null)
7375
}`
@@ -84,7 +86,7 @@ export async function generateModelString(
8486
const instance = new ${modelName}Model(null)
8587
8688
if (instance.softDeletes) {
87-
return await db.updateTable('transactions')
89+
return await db.updateTable('${tableName}')
8890
.set({
8991
deleted_at: sql.raw('CURRENT_TIMESTAMP'),
9092
})
@@ -730,7 +732,7 @@ export async function generateModelString(
730732
export class ${modelName}Model {
731733
private readonly hidden: Array<keyof ${modelName}JsonResponse> = ${hidden}
732734
private readonly fillable: Array<keyof ${modelName}JsonResponse> = ${fillable}
733-
private softDeletes = ${useSoftDeletes}
735+
${privateSoftDeletes}
734736
protected selectFromQuery: any
735737
protected withRelations: string[]
736738
protected updateFromQuery: any
@@ -829,7 +831,7 @@ export async function generateModelString(
829831
830832
const instance = new ${modelName}Model(null)
831833
832-
${instanceSoftDeleteStatements}
834+
${instanceSoftDeleteStatementsSelectFrom}
833835
834836
if (model === undefined)
835837
throw new HttpError(404, \`No ${modelName}Model results for \${id}\`)
@@ -880,11 +882,11 @@ export async function generateModelString(
880882
let models
881883
882884
if (instance.hasSelect) {
883-
${instanceSoftDeleteStatements}
885+
${instanceSoftDeleteStatementsSelectFrom}
884886
885887
models = await instance.selectFromQuery.execute()
886888
} else {
887-
${instanceSoftDeleteStatements}
889+
${instanceSoftDeleteStatementsSelectFrom}
888890
889891
models = await instance.selectFromQuery.selectAll().execute()
890892
}

storage/framework/orm/src/models/AccessToken.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ interface QueryOptions {
5252
export class AccessTokenModel {
5353
private readonly hidden: Array<keyof AccessTokenJsonResponse> = []
5454
private readonly fillable: Array<keyof AccessTokenJsonResponse> = ['name', 'token', 'plain_text_token', 'abilities', 'uuid', 'team_id']
55-
private softDeletes = false
55+
5656
protected selectFromQuery: any
5757
protected withRelations: string[]
5858
protected updateFromQuery: any

storage/framework/orm/src/models/Deployment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ interface QueryOptions {
5757
export class DeploymentModel {
5858
private readonly hidden: Array<keyof DeploymentJsonResponse> = []
5959
private readonly fillable: Array<keyof DeploymentJsonResponse> = ['commit_sha', 'commit_message', 'branch', 'status', 'execution_time', 'deploy_script', 'terminal_output', 'uuid', 'user_id']
60-
private softDeletes = false
60+
6161
protected selectFromQuery: any
6262
protected withRelations: string[]
6363
protected updateFromQuery: any

storage/framework/orm/src/models/Error.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ interface QueryOptions {
4848
export class ErrorModel {
4949
private readonly hidden: Array<keyof ErrorJsonResponse> = []
5050
private readonly fillable: Array<keyof ErrorJsonResponse> = ['type', 'message', 'stack', 'status', 'additional_info', 'uuid']
51-
private softDeletes = false
51+
5252
protected selectFromQuery: any
5353
protected withRelations: string[]
5454
protected updateFromQuery: any

storage/framework/orm/src/models/FailedJob.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ interface QueryOptions {
4848
export class FailedJobModel {
4949
private readonly hidden: Array<keyof FailedJobJsonResponse> = []
5050
private readonly fillable: Array<keyof FailedJobJsonResponse> = ['connection', 'queue', 'payload', 'exception', 'failed_at', 'uuid']
51-
private softDeletes = false
51+
5252
protected selectFromQuery: any
5353
protected withRelations: string[]
5454
protected updateFromQuery: any

storage/framework/orm/src/models/Job.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ interface QueryOptions {
4848
export class JobModel {
4949
private readonly hidden: Array<keyof JobJsonResponse> = []
5050
private readonly fillable: Array<keyof JobJsonResponse> = ['queue', 'payload', 'attempts', 'available_at', 'reserved_at', 'uuid']
51-
private softDeletes = false
51+
5252
protected selectFromQuery: any
5353
protected withRelations: string[]
5454
protected updateFromQuery: any

storage/framework/orm/src/models/PaymentMethod.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ interface QueryOptions {
6161
export class PaymentMethodModel {
6262
private readonly hidden: Array<keyof PaymentMethodJsonResponse> = []
6363
private readonly fillable: Array<keyof PaymentMethodJsonResponse> = ['type', 'last_four', 'brand', 'exp_month', 'exp_year', 'is_default', 'provider_id', 'uuid', 'user_id']
64-
private softDeletes = false
64+
6565
protected selectFromQuery: any
6666
protected withRelations: string[]
6767
protected updateFromQuery: any

storage/framework/orm/src/models/Post.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ interface QueryOptions {
5050
export class PostModel {
5151
private readonly hidden: Array<keyof PostJsonResponse> = []
5252
private readonly fillable: Array<keyof PostJsonResponse> = ['title', 'body', 'uuid', 'user_id']
53-
private softDeletes = false
53+
5454
protected selectFromQuery: any
5555
protected withRelations: string[]
5656
protected updateFromQuery: any

storage/framework/orm/src/models/Product.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ interface QueryOptions {
5252
export class ProductModel {
5353
private readonly hidden: Array<keyof ProductJsonResponse> = []
5454
private readonly fillable: Array<keyof ProductJsonResponse> = ['name', 'description', 'key', 'unit_price', 'status', 'image', 'provider_id', 'uuid']
55-
private softDeletes = false
55+
5656
protected selectFromQuery: any
5757
protected withRelations: string[]
5858
protected updateFromQuery: any

storage/framework/orm/src/models/Project.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ interface QueryOptions {
4747
export class ProjectModel {
4848
private readonly hidden: Array<keyof ProjectJsonResponse> = []
4949
private readonly fillable: Array<keyof ProjectJsonResponse> = ['name', 'description', 'url', 'status', 'uuid']
50-
private softDeletes = false
50+
5151
protected selectFromQuery: any
5252
protected withRelations: string[]
5353
protected updateFromQuery: any

0 commit comments

Comments
 (0)