aboutsummaryrefslogtreecommitdiff
path: root/development/libs/barrel/src/tests/pg/reference.rs
diff options
context:
space:
mode:
Diffstat (limited to 'development/libs/barrel/src/tests/pg/reference.rs')
-rw-r--r--development/libs/barrel/src/tests/pg/reference.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/development/libs/barrel/src/tests/pg/reference.rs b/development/libs/barrel/src/tests/pg/reference.rs
new file mode 100644
index 000000000000..4980e6d7b601
--- /dev/null
+++ b/development/libs/barrel/src/tests/pg/reference.rs
@@ -0,0 +1,19 @@
+#![allow(unused_imports)]
+
+use crate::backend::{Pg, SqlGenerator};
+use crate::{types, Migration, Table};
+
+
+#[test]
+fn in_schema() {
+ let sql = Pg::add_column(false, Some("schema"), "author", &types::foreign("users", "id"));
+
+ assert_eq!(sql, "\"author\" INTEGER REFERENCES \"schema\".\"users\"(id) NOT NULL");
+}
+
+#[test]
+fn ext_schema() {
+ let sql = Pg::add_column(false, Some("schema"), "author", &types::foreign_schema("other_schema", "users", "id"));
+
+ assert_eq!(sql, "\"author\" INTEGER REFERENCES \"other_schema\".\"users\"(id) NOT NULL");
+} \ No newline at end of file