Skip to content

Code generation error : outputted Go package name with '/' not supported #3937

Open
@bemoche

Description

@bemoche

Version

1.29.0

What happened?

Code generation with SQLite errors out when the output package name has '/' in it.

Relevant log output

// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.29.0

package internal/db

import (
	"context"
	"database/sql"
)

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

func New(db DBTX) *Queries {
	return &Queries{db: db}
}

type Queries struct {
	db DBTX
}

func (q *Queries) WithTx(tx *sql.Tx) *Queries {
	return &Queries{
		db: tx,
	}
}

# package internal/db
error generating code: source error: 7:17: expected ';', found '/'

Database schema

-- +goose Up
CREATE TABLE users (
    id SERIAL PRIMARY KEY,
    email VARCHAR(255) NOT NULL,
    password VARCHAR(255) NOT NULL,
    first_name VARCHAR(255),
    last_name VARCHAR(255),
    created_at TIMESTAMP NOT NULL DEFAULT (NOW()),
    updated_at TIMESTAMP NOT NULL DEFAULT (NOW()),
    deleted_at TIMESTAMP,
    deleted BOOLEAN NOT NULL DEFAULT FALSE
);

-- +goose Down
DROP TABLE users;

SQL queries

-- name: CreateUser :one
INSERT INTO users (email, password, first_name, last_name)
VALUES (?, ?, ?, ?)
RETURNING *;

Configuration

version: "2"
sql:
  - engine: "sqlite"
    queries: "internal/db/sql/queries"
    schema: "internal/db/sql/schema"
    database:
      uri: "http://localhost:9000"
    gen:
      go:
        package: "internal/db"
        out: "internal/db/sqlc"

Playground URL

No response

What operating system are you using?

macOS

What database engines are you using?

SQLite

What type of code are you generating?

Go

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