OpenAlchemy icon indicating copy to clipboard operation
OpenAlchemy copied to clipboard

foreign key in x-composite-index

Open Arzemn opened this issue 4 years ago • 0 comments

As a user I want to have the ability to add a foreign key to an x-composite-index

Currently when adding a foreign key into the x-composite-index it generates a key error at the composite index creation step

Example:

ProjectDB:
      description: Basic Project Row
      type: object
      x-tablename: project
      properties:
        id:
          type: integer
          description: Unique identifier for the project 
          example: 0
          x-primary-key: true
          x-autoincrement: true
       project_id:
          type: integer
          description: Unique identifier for the project to the Server   
        server_id:
          $ref: "#/components/schemas/ServerDB"
       x-composite-index:
          - project_id
          - server_id

Results in

KeyError: 'server_id'

Even attempting to use the underlying foreign key "server_id_id" fails

 x-composite-index:
          - project_id
          - server_id_id

Result

open_alchemy.exceptions.MalformedSchemaError: ProjectDB :: x-composite-index :: all expressions must be properties, server_id_id is not

only way to overcome is to define the relation manually,

Arzemn avatar Jul 13 '21 17:07 Arzemn