-
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.
- Loading branch information
Showing
3 changed files
with
23 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import assert from 'node:assert'; | ||
import { TableModel } from '@eggjs/dal-decorator'; | ||
import { Foo } from './fixtures/modules/dal/Foo'; | ||
import { SqlMapLoader } from '../src/SqlMapLoader'; | ||
import path from 'node:path'; | ||
|
||
describe('test/TableSqlMap.test.ts', () => { | ||
it('custom sql should work', () => { | ||
// const generator = new SqlGenerator(); | ||
const fooModel = TableModel.build(Foo); | ||
// const sql = generator.generate(fooModel); | ||
const sqlMapLoader = new SqlMapLoader(fooModel, path.join(__dirname, 'fixtures/modules/dal'), console); | ||
const tableSqlMap = sqlMapLoader.load(); | ||
const sql = tableSqlMap.generate('findAll', {}, 'UTC'); | ||
assert.equal(sql, 'SELECT `id`,`name`,`col1`,`bit_column`,`bool_column`,`tiny_int_column`,`small_int_column`,`medium_int_column`,`int_column`,`big_int_column`,`decimal_column`,`float_column`,`double_column`,`date_column`,`date_time_column`,`timestamp_column`,`time_column`,`year_column`,`var_char_column`,`binary_column`,`var_binary_column`,`tiny_blob_column`,`tiny_text_column`,`blob_column`,`text_column`,`medium_blob_column`,`long_blob_column`,`medium_text_column`,`long_text_column`,`enum_column`,`set_column`,`geometry_column`,`point_column`,`line_string_column`,`polygon_column`,`multipoint_column`,`multi_line_string_column`,`multi_polygon_column`,`geometry_collection_column`,`json_column` from egg_foo;'); | ||
}); | ||
}); |
7 changes: 5 additions & 2 deletions
7
core/dal-runtime/test/fixtures/modules/dal/dal/extension/FooExtension.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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
import { SqlMap } from '@eggjs/dal-decorator'; | ||
import { SqlMap, SqlType } from '@eggjs/dal-decorator'; | ||
|
||
export default { | ||
|
||
findAll: { | ||
type: SqlType.SELECT, | ||
sql: 'SELECT {{ allColumns}} from egg_foo;' | ||
}, | ||
} as Record<string, SqlMap>; |