Skip to content

SQL query syntax for enums #3434

@mazecrown

Description

@mazecrown

I am using C# and I have a column defined in a table using an enum like so:

[Type]
public enum Topping
{
    Cheese,
    Ham,
    Mushroom,
}

[Table(Name = "pizza", Public = true)]
public partial class Pizza
{
    [AutoInc]
    [PrimaryKey]
    public int Id;
    public Topping Topping;
}

When I query "SELECT * from pizza" I get a result like:

 Id   | Topping        
------+----------------
 2248 | (Cheese = ())  
 2249 | (Ham = ())     
 2250 | (Ham = ())     

But what is the syntax for querying based on the Topping column e.g. "SELECT * from pizza WHERE Topping = Ham"?
I couldn't find any info in the docs about this. It would be a welcome addition to add some examples of queries with WHERE clauses on other data types e.g. enums and structs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions