Skip to content

View support #193

Description

@maxhawkins
CREATE TABLE foo (bar INT);

CREATE VIEW baz AS
  SELECT *
  FROM foo;

Should generate:

type Foo struct {
  Bar int
}
type Baz struct {
  Bar int
}

Currently no structs are generated for views.

Activity

  1. ereyes01 commented on Feb 27, 2020

    @ereyes01
    Contributor

    I just found this package and it looks super useful. One of the first things I did was to search the issues to see if there was any insight on how views are handled, and found this.

    Is the DDL code given ever actually run in the database? If it's only used to generate the structs, would a valid workaround be:

    CREATE TABLE foo (bar INT);
    
    CREATE TABLE baz (bar INT);

    And then design your queries of baz as normal, since the DDL is only for deriving and generating the Baz Go struct?

    I acknowledge that it's not as convenient or robust as copy/pasting the same thing you run in the database, and sometimes it's extra work to determine the equivalent CREATE TABLE command from a complex view query.

    Thanks!

  2. kyleconroy commented on Mar 1, 2020

    @kyleconroy
    Collaborator

    @ereyes01 That's a good work around for the time being. The eventual goal is to fully support view creation and querying.

  3. randomlogin commented on Sep 3, 2020

    @randomlogin

    Hi!
    I'm using 1.5.0, am I right, that views are not supported there yet?
    The only workaround is to construct appropriate table?

  4. philipjscott commented on Oct 4, 2020

    @philipjscott

    Hi @kyleconroy! Really love sqlc; I'm wondering if there's any plans to tackle views any time soon? I'd willing to help out 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions