-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!-- Thank you for your pull request. Please review below requirements. Bug fixes and new features should include tests and possibly benchmarks. Contributors guide: https://github.com/eggjs/egg/blob/master/CONTRIBUTING.md 感谢您贡献代码。请确认下列 checklist 的完成情况。 Bug 修复和新功能必须包含测试,必要时请附上性能测试。 Contributors guide: https://github.com/eggjs/egg/blob/master/CONTRIBUTING.md --> ##### Checklist <!-- Remove items that do not apply. For completed items, change [ ] to [x]. --> - [ ] `npm test` passes - [ ] tests and/or benchmarks are included - [ ] documentation is changed or added - [ ] commit message follows commit guidelines ##### Affected core subsystem(s) <!-- Provide affected core subsystem(s). --> ##### Description of change <!-- Provide a description of the change below this comment. --> <!-- - any feature? - close https://github.com/eggjs/egg/ISSUE_URL --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a configuration option to control whether existing files should be overwritten during code generation. - Added custom operation capabilities in the Data Access Layer for enhanced data handling. - **Bug Fixes** - Implemented a test to ensure data integrity by preventing overwriting of existing files during code generation. - **Chores** - Updated `.gitignore` to better manage file tracking within the project. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
Showing
6 changed files
with
376 additions
and
1 deletion.
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
323 changes: 323 additions & 0 deletions
323
core/dal-runtime/test/fixtures/modules/generate_codes_not_overwrite_dao/Foo.ts
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,323 @@ | ||
import { | ||
Column, | ||
ColumnType, | ||
Geometry, | ||
GeometryCollection, | ||
Index, | ||
IndexType, | ||
Line, | ||
IndexStoreType, | ||
MultiLine, | ||
MultiPoint, | ||
MultiPolygon, | ||
Point, | ||
Polygon, | ||
Table, | ||
} from '@eggjs/dal-decorator'; | ||
|
||
@Table({ | ||
name: 'egg_foo', | ||
comment: 'foo table', | ||
// autoExtendSize: 1024, | ||
// autoIncrement: 100, | ||
// avgRowLength: 1024, | ||
characterSet: 'utf8mb4', | ||
collate: 'utf8mb4_unicode_ci', | ||
// compression: CompressionType.ZLIB, | ||
// encryption: true, | ||
// engine: 'NDB', | ||
// engineAttribute: '{"key":"value"}', | ||
// secondaryEngineAttribute: '{"key2":"value2"}', | ||
// insertMethod: InsertMethod.FIRST, | ||
// keyBlockSize: 1024, | ||
// maxRows: 1000000, | ||
// minRows: 100, | ||
// rowFormat: RowFormat.COMPRESSED, | ||
}) | ||
@Index({ | ||
keys: [ 'name', 'col1' ], | ||
type: IndexType.UNIQUE, | ||
storeType: IndexStoreType.BTREE, | ||
comment: 'index comment\n', | ||
// engineAttribute: '{"key":"value"}', | ||
// secondaryEngineAttribute: '{"key2":"value2"}', | ||
}) | ||
@Index({ | ||
keys: [ 'col1' ], | ||
type: IndexType.FULLTEXT, | ||
comment: 'index comment\n', | ||
// engineAttribute: '{"key":"value"}', | ||
// secondaryEngineAttribute: '{"key2":"value2"}', | ||
// parser: 'foo', | ||
}) | ||
export class Foo { | ||
@Column({ | ||
type: ColumnType.INT, | ||
}, { | ||
primaryKey: true, | ||
autoIncrement: true, | ||
comment: 'the primary key', | ||
}) | ||
id: number; | ||
|
||
@Column({ | ||
type: ColumnType.VARCHAR, | ||
length: 100, | ||
}, { | ||
uniqueKey: true, | ||
}) | ||
name: string; | ||
|
||
@Column({ | ||
type: ColumnType.VARCHAR, | ||
length: 100, | ||
}, { | ||
name: 'col1', | ||
}) | ||
col1: string; | ||
|
||
@Column({ | ||
type: ColumnType.BIT, | ||
length: 10, | ||
}) | ||
bitColumn: Buffer; | ||
|
||
@Column({ | ||
type: ColumnType.BOOL, | ||
}) | ||
boolColumn: 0 | 1; | ||
|
||
@Column({ | ||
type: ColumnType.TINYINT, | ||
length: 5, | ||
unsigned: true, | ||
zeroFill: true, | ||
}) | ||
tinyIntColumn: number; | ||
|
||
@Column({ | ||
type: ColumnType.SMALLINT, | ||
length: 5, | ||
unsigned: true, | ||
zeroFill: true, | ||
}) | ||
smallIntColumn: number; | ||
|
||
@Column({ | ||
type: ColumnType.MEDIUMINT, | ||
length: 5, | ||
unsigned: true, | ||
zeroFill: true, | ||
}) | ||
mediumIntColumn: number; | ||
|
||
@Column({ | ||
type: ColumnType.INT, | ||
length: 5, | ||
unsigned: true, | ||
zeroFill: true, | ||
}) | ||
intColumn: number; | ||
|
||
@Column({ | ||
type: ColumnType.BIGINT, | ||
length: 5, | ||
unsigned: true, | ||
zeroFill: true, | ||
}) | ||
bigIntColumn: string; | ||
|
||
@Column({ | ||
type: ColumnType.DECIMAL, | ||
length: 10, | ||
fractionalLength: 5, | ||
unsigned: true, | ||
zeroFill: true, | ||
}) | ||
decimalColumn: string; | ||
|
||
@Column({ | ||
type: ColumnType.FLOAT, | ||
length: 10, | ||
fractionalLength: 5, | ||
unsigned: true, | ||
zeroFill: true, | ||
}) | ||
floatColumn: number; | ||
|
||
@Column({ | ||
type: ColumnType.DOUBLE, | ||
length: 10, | ||
fractionalLength: 5, | ||
unsigned: true, | ||
zeroFill: true, | ||
}) | ||
doubleColumn: number; | ||
|
||
@Column({ | ||
type: ColumnType.DATE, | ||
}) | ||
dateColumn: Date; | ||
|
||
@Column({ | ||
type: ColumnType.DATETIME, | ||
precision: 3, | ||
}) | ||
dateTimeColumn: Date; | ||
|
||
@Column({ | ||
type: ColumnType.TIMESTAMP, | ||
precision: 3, | ||
}) | ||
timestampColumn: Date; | ||
|
||
@Column({ | ||
type: ColumnType.TIME, | ||
precision: 3, | ||
}) | ||
timeColumn: string; | ||
|
||
@Column({ | ||
type: ColumnType.YEAR, | ||
}) | ||
yearColumn: number; | ||
|
||
@Column({ | ||
type: ColumnType.VARCHAR, | ||
length: 100, | ||
characterSet: 'utf8mb4', | ||
collate: 'utf8mb4_unicode_ci', | ||
}) | ||
varCharColumn: string; | ||
|
||
@Column({ | ||
type: ColumnType.BINARY, | ||
}) | ||
binaryColumn: Buffer; | ||
|
||
@Column({ | ||
type: ColumnType.VARBINARY, | ||
length: 100, | ||
}) | ||
varBinaryColumn: Buffer; | ||
|
||
@Column({ | ||
type: ColumnType.TINYBLOB, | ||
}) | ||
tinyBlobColumn: Buffer; | ||
|
||
@Column({ | ||
type: ColumnType.TINYTEXT, | ||
characterSet: 'utf8mb4', | ||
collate: 'utf8mb4_unicode_ci', | ||
}) | ||
tinyTextColumn: string; | ||
|
||
@Column({ | ||
type: ColumnType.BLOB, | ||
length: 100, | ||
}) | ||
blobColumn: Buffer; | ||
|
||
@Column({ | ||
type: ColumnType.TEXT, | ||
length: 100, | ||
characterSet: 'utf8mb4', | ||
collate: 'utf8mb4_unicode_ci', | ||
}) | ||
textColumn: string; | ||
|
||
@Column({ | ||
type: ColumnType.MEDIUMBLOB, | ||
}) | ||
mediumBlobColumn: Buffer; | ||
|
||
@Column({ | ||
type: ColumnType.LONGBLOB, | ||
}) | ||
longBlobColumn: Buffer; | ||
|
||
@Column({ | ||
type: ColumnType.MEDIUMTEXT, | ||
characterSet: 'utf8mb4', | ||
collate: 'utf8mb4_unicode_ci', | ||
}) | ||
mediumTextColumn: string; | ||
|
||
@Column({ | ||
type: ColumnType.LONGTEXT, | ||
characterSet: 'utf8mb4', | ||
collate: 'utf8mb4_unicode_ci', | ||
}) | ||
longTextColumn: string; | ||
|
||
@Column({ | ||
type: ColumnType.ENUM, | ||
enums: [ 'A', 'B' ], | ||
characterSet: 'utf8mb4', | ||
collate: 'utf8mb4_unicode_ci', | ||
}) | ||
enumColumn: string; | ||
|
||
@Column({ | ||
type: ColumnType.SET, | ||
enums: [ 'A', 'B' ], | ||
characterSet: 'utf8mb4', | ||
collate: 'utf8mb4_unicode_ci', | ||
}) | ||
setColumn: string; | ||
|
||
@Column({ | ||
type: ColumnType.GEOMETRY, | ||
// SRID: 4326, | ||
}) | ||
geometryColumn: Geometry; | ||
|
||
|
||
@Column({ | ||
type: ColumnType.POINT, | ||
// SRID: 4326, | ||
}) | ||
pointColumn: Point; | ||
|
||
@Column({ | ||
type: ColumnType.LINESTRING, | ||
// SRID: 4326, | ||
}) | ||
lineStringColumn: Line; | ||
|
||
@Column({ | ||
type: ColumnType.POLYGON, | ||
// SRID: 4326, | ||
}) | ||
polygonColumn: Polygon; | ||
|
||
@Column({ | ||
type: ColumnType.MULTIPOINT, | ||
// SRID: 4326, | ||
}) | ||
multipointColumn: MultiPoint; | ||
|
||
@Column({ | ||
type: ColumnType.MULTILINESTRING, | ||
// SRID: 4326, | ||
}) | ||
multiLineStringColumn: MultiLine; | ||
|
||
@Column({ | ||
type: ColumnType.MULTIPOLYGON, | ||
// SRID: 4326, | ||
}) | ||
multiPolygonColumn: MultiPolygon; | ||
|
||
@Column({ | ||
type: ColumnType.GEOMETRYCOLLECTION, | ||
// SRID: 4326, | ||
}) | ||
geometryCollectionColumn: GeometryCollection; | ||
|
||
@Column({ | ||
type: ColumnType.JSON, | ||
}) | ||
jsonColumn: object; | ||
} |
Oops, something went wrong.