Skip to content

emoji in queries generate broken queries聽#3478

Open

Description

@josharian

Version

1.26.0

What happened?

In query.sql:

-- name: EmojiOops :exec
SELECT
    '馃し' AS emoji
limit
    1;

Generated in query.sql.go:

const emojiOops = `-- name: EmojiOops :exec
SELECT
    '馃し' AS emoji
limit
`

Observe the missing 1; at the end. Looks like somebody is counting bytes instead of runes?

Yes, this happened in real code. It was pretty confusing to debug.

Appears to be happen with some dbs and not others? Didn't dig much.

Relevant log output

No response

Database schema

No response

SQL queries

No response

Configuration

---
version: 2
sql:
  - engine: sqlite
    schema: schema.sql
    queries: query.sql
    gen:
      go:
        package: [redacted]
        out: .
        emit_exact_table_names: true
        emit_result_struct_pointers: true
        emit_params_struct_pointers: true
        query_parameter_limit: 3
        output_db_file_name: sqlc.go

Playground URL

https://play.sqlc.dev/p/984f440606d6a2084f363f711e283a31b031901ea70d613a250636784d5cad33

What operating system are you using?

Linux, macOS

What database engines are you using?

SQLite

What type of code are you generating?

Go

Activity

  1. added
    bugSomething isn't working
    triageNew issues that hasn't been reviewed
    on Jul 5, 2024
  2. 1AbdulkarimMousa commented on Jul 10, 2024

    @1AbdulkarimMousa

    I don't think that you can have a such a field in a struct !

    type Table Struct {
    馃し string ,
    ...
    }

    I don't know what framework frontend technology your are using , but json/xml common unMarshalers won't parse your field correctly . I know this won't help.

    But if it is a must , I suggest you to create custom go code to adapt the SQLC model structs => your response structs/json/xml/whatever_format .

  3. josharian commented on Jul 10, 2024

    @josharian
    ContributorAuthor

    I don't think that you can have a such a field in a struct !

    AS emoji in the query changes the name to Emoji.

  4. removed
    triageNew issues that hasn't been reviewed
    on Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions