Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: clarify nullable override behavior #2753

Merged
merged 2 commits into from
Sep 21, 2023
Merged

Conversation

andrewmbenton
Copy link
Collaborator

  • also remove some dead code

* also remove some dead code
@daison12006013
Copy link

daison12006013 commented Sep 21, 2023

@andrewmbenton is there a documentation as well if we can re-use a certain override block in sqlc.yaml?

overrides:
  go:
    overrides:
      - column: "profiles.payment_flag"
      - column: "profileviews.is_active_member"
      - column: "profileviews.is_active_profile"
        nullable: true
        go_type:
          import: "gopkg.in/guregu/null.v4"
          package: "null"
          type: "Bool"
      
      - db_type: "varchar"
      - db_type: "text"
      - db_type: "json"
        nullable: true
        go_type:
          import: "gopkg.in/guregu/null.v4"
          package: "null"
          type: "String"

As an example above, where in the 3 columns will have a null.Bool.

Meanwhile I am using anchors, somewhat like this

      # Boolean specific columns
      - column: "profiles.payment_flag"
        nullable: true
        go_type: &nullBoolean
          import: "gopkg.in/guregu/null.v4"
          package: "null"
          type: "Bool"
      - column: "profileviews.is_active_member"
        nullable: true
        go_type: *nullBoolean
      - column: "profileviews.is_active_profile"
        nullable: true
        go_type: *nullBoolean

      # String
      - db_type: "varchar"
        nullable: true
        go_type: &nullString
          import: "gopkg.in/guregu/null.v4"
          package: "null"
          type: "String"
      - db_type: "text"
        nullable: true
        go_type: *nullString
      - db_type: "json"
        nullable: true
        go_type: *nullString

@andrewmbenton
Copy link
Collaborator Author

As an example above, where in the 3 columns will have a null.Bool.

This "fallthrough" behavior won't work as far as I know, although I think it is technically possible to implement. The anchors solution seems like the best way to reduce redundancy at the moment.

@andrewmbenton andrewmbenton merged commit ac32049 into main Sep 21, 2023
8 checks passed
@andrewmbenton andrewmbenton deleted the andrew/docs-update branch September 21, 2023 16:15
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants