unsupported_constraints_test.go 828 B

123456789101112131415161718192021
  1. package pgserver
  2. import (
  3. "testing"
  4. )
  5. func TestCheckAndForeignKeyRejectedOverSimpleQuery(t *testing.T) {
  6. c, client := newDataConnection(t)
  7. runQuery(t, c, client, &Message{Type: MsgQuery, Data: append([]byte("CREATE TABLE parent (id INTEGER PRIMARY KEY)"), 0)})
  8. for _, sql := range []string{
  9. "CREATE TABLE t1 (id INTEGER PRIMARY KEY, age INTEGER CHECK (age > 0))",
  10. "CREATE TABLE t2 (id INTEGER PRIMARY KEY, parent_id INTEGER REFERENCES parent(id))",
  11. "CREATE TABLE t3 (id INTEGER PRIMARY KEY, parent_id INTEGER, FOREIGN KEY (parent_id) REFERENCES parent(id))",
  12. } {
  13. msgs := runQuery(t, c, client, &Message{Type: MsgQuery, Data: append([]byte(sql), 0)})
  14. if code := errorCode(msgs[0]); code != ErrCodeFeatureNotSupported {
  15. t.Fatalf("%s: error code = %q, want %q", sql, code, ErrCodeFeatureNotSupported)
  16. }
  17. }
  18. }