hasura / hasura/graphql-engine
updated_at Triggers: record \"_new\" has no field \"updated_at\"" with triggers created outside hasura
- Dominant language
- TypeScript
- Stars
- 32.1k
- Forks
- 3k
- PR merge metrics
- PR metrics pending
Description
**Environment:**
- OS: Windows 10 64 Bits
- Docker Environment: Docker Toolbox with Virtualbox
- Hasura: v1.1.0
Hello, we have a desktop app that uses Postgres. And plan to make a mobile app to connect it and hasura is a good idea to works as layer because we don't need make deepp refactor to make data compatible. So just configure hasura to use this database and voilá! Great!
Well 99% fine, we just need to make some adjustments by adding `created_at` and `updated_at` columns on our existing migrations... not on hasura.
Works fine when add new data, but not when updates... as the triggers are not created by hasura, update not works... Gives-me the error: **"record \"_new\" has no field \"updated_at\"",**.
When an `updated_at` column is created using Hasura UI, there is some extra content outside Postgres triggers?
Below, the trigger code:
```sql
CREATE FUNCTION public.set_current_timestamp_updated_at()
RETURNS TRIGGER AS $$
DECLARE
_new record;
BEGIN
_new := NEW;
_new.updated_at = NOW();
RETURN _new;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER set_public_clients_updated_at
BEFORE UPDATE ON public.clients
FOR EACH ROW
EXECUTE PROCEDURE public.set_current_timestamp_updated_at();
```
Contributor guide
Research direction
Use the supplied PostgreSQL trigger SQL and the reported Hasura v1.1.0 environment as the reproduction. Compare an externally created trigger with one created through the Hasura UI, then determine whether the differing behavior is supported or needs a fix; done means the cause and expected handling are established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100