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

VSCode extension complains about trigger #2442

Closed
sincraianul opened this issue Jan 14, 2024 · 3 comments
Closed

VSCode extension complains about trigger #2442

sincraianul opened this issue Jan 14, 2024 · 3 comments
Assignees

Comments

@sincraianul
Copy link

I have the following schema:

schema "common" {
  comment = "common schema"
}

# updated at trigger

function "set_updated_at" {
  schema = schema.common
  lang   = PLpgSQL
  return = trigger
  as     = <<-SQL
  DECLARE
    _new record;
  BEGIN
    _new := NEW;
    _new."updated_at" = NOW();
    RETURN _new;
  END;
  SQL
}

trigger "set_updated_at" {
  for_each = toset([table.workspace])
  on       = each.value
  before {
    update = true
  }
  foreach = "ROW"
  execute  {
    function = function.set_updated_at
  }
}

# common tables

table "workspace" {
  schema = schema.common
  column "id" {
    type = uuid
    null = false
    default = sql("gen_random_uuid()")
  }
  column "name" {
    type = text
    null = false
  }
  column "active" {
    type = boolean
    null = false
    default = true
  }
  column "created_at" {
    type = timestamptz
    null = false
    default = sql("now()")
  }
  column "updated_at" {
    type = timestamptz
    null = false
    default = sql("now()")
  }
  primary_key  {
    columns = [column.id]
  }
  index "workspace_name_key" {
    columns = [column.name]
    unique = true
  }
}

I can apply it fine, so it's definitely valid, but VSCode complains that the syntax is not right:

Screenshot 2024-01-15 at 00 53 36
@giautm
Copy link
Member

giautm commented Jan 15, 2024

Hello @sincraianul, can you please share your version of VSCode extension?

@sincraianul
Copy link
Author

@giautm Latest version, 0.4.2.

@giautm
Copy link
Member

giautm commented Jan 23, 2024

Hello @sincraianul, we updated our Language Server to support trigger. What you need to do for upgrade is close VSCode and reopen, then it should download the new binary and works. Please let me know if it doesn't work for you. Thanks!

@giautm giautm closed this as completed Jan 23, 2024
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

No branches or pull requests

3 participants