deepkit-framework
                                
                                 deepkit-framework copied to clipboard
                                
                                    deepkit-framework copied to clipboard
                            
                            
                            
                        [Bug] Self-Reference Fields Serialized into Nested Objects without Joinning
test('self-reference serialization', async () => {
    class MyEntity {
        id: number & PrimaryKey & AutoIncrement = 0;
        ref?: MyEntity & Reference; //   <---- Self-Reference Field
    }
    const databaseAdapter = new SQLiteDatabaseAdapter(':memory:');
    const schemas = [MyEntity];
    const database = new Database(databaseAdapter, schemas);
    database.logger.enableLogging();
    await database.migrate();
    const entity = new MyEntity();
    entity.ref = new MyEntity();
    await database.persist(entity);
    const entities = await database.query(MyEntity).find();
    expect(serialize<MyEntity[]>(entities)).toEqual([
        expect.anything(),
        { id: 2, ref: 1 }, //    <---- Here `ref` is serialized into an object instead of a primary key
    ]);
});
What does "[Fix]" mean in the title?
corrected 😂
Thanks @TheNightmareX, this should be fixed in master. Please check it out and let me know. (tests added in https://github.com/deepkit/deepkit-framework/commit/aa90b17a28cdf0b081736579c7463920eb97412a)