unsupported_constraints_test.go 818 B

123456789101112131415161718192021
  1. package pgserver
  2. import (
  3. "testing"
  4. )
  5. // CHECK is enforced (see check_test.go); FOREIGN KEY is still rejected.
  6. func TestForeignKeyRejectedOverSimpleQuery(t *testing.T) {
  7. c, client := newDataConnection(t)
  8. runQuery(t, c, client, &Message{Type: MsgQuery, Data: append([]byte("CREATE TABLE parent (id INTEGER PRIMARY KEY)"), 0)})
  9. for _, sql := range []string{
  10. "CREATE TABLE t1 (id INTEGER PRIMARY KEY, parent_id INTEGER REFERENCES parent(id))",
  11. "CREATE TABLE t2 (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. }