Merge branch 'main' into next

This commit is contained in:
nocobase[bot] 2025-05-07 13:43:56 +00:00
commit b6812e1fe5
3 changed files with 72 additions and 0 deletions

View File

@ -112,6 +112,7 @@ export function withInitializer<T>(C: ComponentType<T>) {
React.createElement(C, cProps) React.createElement(C, cProps)
) : ( ) : (
<Popover <Popover
zIndex={9999}
placement={'bottomLeft'} placement={'bottomLeft'}
{...popoverProps} {...popoverProps}
arrow={false} arrow={false}

View File

@ -10,6 +10,8 @@
import Database, { createMockDatabase } from '@nocobase/database'; import Database, { createMockDatabase } from '@nocobase/database';
import { EagerLoadingTree } from '../../eager-loading/eager-loading-tree'; import { EagerLoadingTree } from '../../eager-loading/eager-loading-tree';
const skipSqlite = process.env.DB_DIALECT == 'sqlite' ? it.skip : it;
describe('Eager loading tree', () => { describe('Eager loading tree', () => {
let db: Database; let db: Database;
beforeEach(async () => { beforeEach(async () => {
@ -381,6 +383,69 @@ describe('Eager loading tree', () => {
expect(p1User.get('name')).toBe('u1'); 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 () => { it('should load belongs to many', async () => {
const Post = db.collection({ const Post = db.collection({
name: 'posts', name: 'posts',

View File

@ -7,11 +7,17 @@
* For more information, please refer to: https://www.nocobase.com/agreement. * For more information, please refer to: https://www.nocobase.com/agreement.
*/ */
import { DatabaseOptions } from '../database';
import { BaseDialect } from './base-dialect'; import { BaseDialect } from './base-dialect';
export class MariadbDialect extends BaseDialect { export class MariadbDialect extends BaseDialect {
static dialectName = 'mariadb'; static dialectName = 'mariadb';
getSequelizeOptions(options: DatabaseOptions) {
options.dialectOptions = { ...(options.dialectOptions || {}), supportBigNumbers: true, bigNumberStrings: true };
return options;
}
getVersionGuard() { getVersionGuard() {
return { return {
sql: 'select version() as version', sql: 'select version() as version',