mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-09 15:39:24 +08:00
Merge branch 'main' into next
This commit is contained in:
commit
b6812e1fe5
@ -112,6 +112,7 @@ export function withInitializer<T>(C: ComponentType<T>) {
|
||||
React.createElement(C, cProps)
|
||||
) : (
|
||||
<Popover
|
||||
zIndex={9999}
|
||||
placement={'bottomLeft'}
|
||||
{...popoverProps}
|
||||
arrow={false}
|
||||
|
@ -10,6 +10,8 @@
|
||||
import Database, { createMockDatabase } from '@nocobase/database';
|
||||
import { EagerLoadingTree } from '../../eager-loading/eager-loading-tree';
|
||||
|
||||
const skipSqlite = process.env.DB_DIALECT == 'sqlite' ? it.skip : it;
|
||||
|
||||
describe('Eager loading tree', () => {
|
||||
let db: Database;
|
||||
beforeEach(async () => {
|
||||
@ -381,6 +383,69 @@ describe('Eager loading tree', () => {
|
||||
expect(p1User.get('name')).toBe('u1');
|
||||
});
|
||||
|
||||
skipSqlite('should load belongs to on bigint foreign key', async () => {
|
||||
const Post = db.collection({
|
||||
name: 'posts',
|
||||
fields: [
|
||||
{ type: 'string', name: 'title' },
|
||||
{
|
||||
type: 'belongsTo',
|
||||
name: 'user',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const User = db.collection({
|
||||
name: 'users',
|
||||
fields: [{ type: 'string', name: 'name' }],
|
||||
});
|
||||
|
||||
await db.sync();
|
||||
|
||||
await Post.repository.create({
|
||||
values: [
|
||||
{
|
||||
title: 'p1',
|
||||
user: {
|
||||
name: 'u1',
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'p2',
|
||||
user: {
|
||||
id: '19051207196672111',
|
||||
name: 'u2',
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const findOptions = Post.repository.buildQueryOptions({
|
||||
appends: ['user'],
|
||||
});
|
||||
|
||||
const eagerLoadingTree = EagerLoadingTree.buildFromSequelizeOptions({
|
||||
model: Post.model,
|
||||
rootAttributes: findOptions.attributes,
|
||||
includeOption: findOptions.include,
|
||||
db: db,
|
||||
rootQueryOptions: findOptions,
|
||||
});
|
||||
|
||||
await eagerLoadingTree.load();
|
||||
|
||||
const root = eagerLoadingTree.root;
|
||||
const p1 = root.instances.find((item) => item.get('title') === 'p1');
|
||||
const p1User = p1.get('user') as any;
|
||||
expect(p1User).toBeDefined();
|
||||
expect(p1User.get('name')).toBe('u1');
|
||||
|
||||
const p2 = root.instances.find((item) => item.get('title') === 'p2');
|
||||
const p2User = p2.get('user') as any;
|
||||
expect(p2User).toBeDefined();
|
||||
expect(p2User.get('name')).toBe('u2');
|
||||
});
|
||||
|
||||
it('should load belongs to many', async () => {
|
||||
const Post = db.collection({
|
||||
name: 'posts',
|
||||
|
@ -7,11 +7,17 @@
|
||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||
*/
|
||||
|
||||
import { DatabaseOptions } from '../database';
|
||||
import { BaseDialect } from './base-dialect';
|
||||
|
||||
export class MariadbDialect extends BaseDialect {
|
||||
static dialectName = 'mariadb';
|
||||
|
||||
getSequelizeOptions(options: DatabaseOptions) {
|
||||
options.dialectOptions = { ...(options.dialectOptions || {}), supportBigNumbers: true, bigNumberStrings: true };
|
||||
return options;
|
||||
}
|
||||
|
||||
getVersionGuard() {
|
||||
return {
|
||||
sql: 'select version() as version',
|
||||
|
Loading…
x
Reference in New Issue
Block a user