fix: create inherits from a table that has no id (#1104)
* fix: create inherits from no id table * chore: console.log
This commit is contained in:
		
							parent
							
								
									395c441b21
								
							
						
					
					
						commit
						8cad307fbb
					
				@ -15,6 +15,35 @@ pgOnly()('collection inherits', () => {
 | 
			
		||||
    await db.close();
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('should inherit from no id table', async () => {
 | 
			
		||||
    const interfaceCollection = db.collection({
 | 
			
		||||
      name: 'a',
 | 
			
		||||
      fields: [
 | 
			
		||||
        {
 | 
			
		||||
          type: 'string',
 | 
			
		||||
          name: 'name',
 | 
			
		||||
        },
 | 
			
		||||
      ],
 | 
			
		||||
      timestamps: false,
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    interfaceCollection.model.removeAttribute('id');
 | 
			
		||||
    const child = db.collection({
 | 
			
		||||
      name: 'b',
 | 
			
		||||
      inherits: ['a'],
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    await db.sync();
 | 
			
		||||
 | 
			
		||||
    const childInstance = await child.repository.create({
 | 
			
		||||
      values: {
 | 
			
		||||
        name: 'test',
 | 
			
		||||
      },
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    expect(childInstance.get('name')).toBe('test');
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('should pass empty inherits params', async () => {
 | 
			
		||||
    const table1 = db.collection({
 | 
			
		||||
      name: 'table1',
 | 
			
		||||
 | 
			
		||||
@ -40,6 +40,11 @@ export class SyncRunner {
 | 
			
		||||
            transaction,
 | 
			
		||||
          },
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        if (!sequenceNameResult[0].length) {
 | 
			
		||||
          continue;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        const columnDefault = sequenceNameResult[0][0]['column_default'];
 | 
			
		||||
 | 
			
		||||
        if (!columnDefault) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user