MCPcopy
hub / github.com/pocketbase/pocketbase / TestCollectionSaveViewWrapping

Function TestCollectionSaveViewWrapping

core/collection_model_test.go:1574–1680  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1572}
1573
1574func TestCollectionSaveViewWrapping(t *testing.T) {
1575 t.Parallel()
1576
1577 viewName := "test_wrapping"
1578
1579 // note: some of the queries use "limit 0" because the tested field value could be empty
1580 // which will trigger the extra sample records validation that are not important for this test
1581 scenarios := []struct {
1582 name string
1583 query string
1584 expected string
1585 }{
1586 {
1587 "no wrapping - id field",
1588 "select id, bool from demo1",
1589 "CREATE VIEW `test_wrapping` AS SELECT * FROM (select id, bool from demo1)",
1590 },
1591 {
1592 "no wrapping - text field",
1593 "select text as id, bool from demo1 limit 0",
1594 "CREATE VIEW `test_wrapping` AS SELECT * FROM (select text as id, bool from demo1 limit 0)",
1595 },
1596 {
1597 "no wrapping - relation field",
1598 "select rel_one as id, bool from demo1 limit 0",
1599 "CREATE VIEW `test_wrapping` AS SELECT * FROM (select rel_one as id, bool from demo1 limit 0)",
1600 },
1601 {
1602 "no wrapping - select field",
1603 "select select_many as id, bool from demo1 limit 0",
1604 "CREATE VIEW `test_wrapping` AS SELECT * FROM (select select_many as id, bool from demo1 limit 0)",
1605 },
1606 {
1607 "no wrapping - email field",
1608 "select email as id, bool from demo1 limit 0",
1609 "CREATE VIEW `test_wrapping` AS SELECT * FROM (select email as id, bool from demo1 limit 0)",
1610 },
1611 {
1612 "no wrapping - datetime field",
1613 "select datetime as id, bool from demo1 limit 0",
1614 "CREATE VIEW `test_wrapping` AS SELECT * FROM (select datetime as id, bool from demo1 limit 0)",
1615 },
1616 {
1617 "no wrapping - url field",
1618 "select url as id, bool from demo1 limit 0",
1619 "CREATE VIEW `test_wrapping` AS SELECT * FROM (select url as id, bool from demo1 limit 0)",
1620 },
1621 {
1622 "wrapping - bool field",
1623 "select bool as id, text as txt, url from demo1 limit 0",
1624 "CREATE VIEW `test_wrapping` AS SELECT * FROM (SELECT CAST(`id` as TEXT) `id`,`txt`,`url` FROM (select bool as id, text as txt, url from demo1 limit 0))",
1625 },
1626 {
1627 "wrapping - bool field (different order)",
1628 "select text as txt, url, bool as id from demo1 limit 0",
1629 "CREATE VIEW `test_wrapping` AS SELECT * FROM (SELECT `txt`,`url`,CAST(`id` as TEXT) `id` FROM (select text as txt, url, bool as id from demo1 limit 0))",
1630 },
1631 {

Callers

nothing calls this directly

Calls 8

CleanupMethod · 0.95
NewTestAppFunction · 0.92
NewViewCollectionFunction · 0.92
NewQueryMethod · 0.80
SaveMethod · 0.65
ConcurrentDBMethod · 0.65
RunMethod · 0.45
BindMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…