subsquid / squid-sdk

The main repo of the squid SDK
Apache License 2.0
1.23k stars 151 forks source link

Missing typorm Index import when only using multi-column indices #157

Closed maflohr closed 1 year ago

maflohr commented 1 year ago

Describe the bug Codegen does not include typeorm's Index as Index_ when only using multi-column indices.

To Reproduce Steps to reproduce the behavior:

  1. Clone the squid-substrate-template repository

  2. npm run update && npm ci

  3. Edit the schema.graphql to only include the following lines

    type AliceBob @entity @index(fields: ["alice", "bob"]) {
    alice: String!
    bob: String!
    }
  4. Run sqd codegen

  5. See that the src/model/generated/aliceBob.model.ts uses the unreferenced @Index_ decorator

    
    import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_} from "typeorm"

@Index(["alice", "bob"], {unique: false}) @Entity() export class AliceBob { ...


**Expected behavior**
The `Index as Index_` import should be added to the generated model.

import {Entity as Entity, Column as Column, PrimaryColumn as PrimaryColumn, Index as Index} from "typeorm"

@Index(["alice", "bob"], {unique: false}) @Entity() export class AliceBob { ...



**Environment (please complete the following information):**
 - @subsquid/cli (2.1.0)
 - node.js v16.16.0
 - npm 9.4.1
 - OS Ubuntu 20.04.5 LTS, 5.10.102.1-microsoft-standard-WSL2