MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / cursor_by_many

Function cursor_by_many

src/executor/cursor.rs:1836–1955  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1834
1835 #[smol_potat::test]
1836 async fn cursor_by_many() -> Result<(), DbErr> {
1837 use composite_entity::*;
1838
1839 let base_sql = [
1840 r#"SELECT "t"."col_1", "t"."col_2", "t"."col_3", "t"."col_4", "t"."col_5", "t"."col_6", "t"."col_7", "t"."col_8", "t"."col_9", "t"."col_10", "t"."col_11", "t"."col_12""#,
1841 r#"FROM "t" WHERE"#,
1842 ].join(" ");
1843
1844 assert_eq!(
1845 DbBackend::Postgres.build(&
1846 Entity::find()
1847 .cursor_by((Column::Col1, Column::Col2, Column::Col3, Column::Col4))
1848 .after(("val_1", "val_2", "val_3", "val_4")).apply_limit().apply_order_by().apply_filters().query
1849 ).to_string(),
1850 format!("{base_sql} {}", [
1851 r#"("t"."col_1" = 'val_1' AND "t"."col_2" = 'val_2' AND "t"."col_3" = 'val_3' AND "t"."col_4" > 'val_4')"#,
1852 r#"OR ("t"."col_1" = 'val_1' AND "t"."col_2" = 'val_2' AND "t"."col_3" > 'val_3')"#,
1853 r#"OR ("t"."col_1" = 'val_1' AND "t"."col_2" > 'val_2')"#,
1854 r#"OR "t"."col_1" > 'val_1'"#,
1855 r#"ORDER BY "t"."col_1" ASC, "t"."col_2" ASC, "t"."col_3" ASC, "t"."col_4" ASC"#,
1856 ].join(" "))
1857 );
1858
1859 assert_eq!(
1860 DbBackend::Postgres.build(&
1861 Entity::find()
1862 .cursor_by((Column::Col1, Column::Col2, Column::Col3, Column::Col4, Column::Col5))
1863 .after(("val_1", "val_2", "val_3", "val_4", "val_5")).apply_limit().apply_order_by().apply_filters()
1864 .query
1865 ).to_string(),
1866 format!("{base_sql} {}", [
1867 r#"("t"."col_1" = 'val_1' AND "t"."col_2" = 'val_2' AND "t"."col_3" = 'val_3' AND "t"."col_4" = 'val_4' AND "t"."col_5" > 'val_5')"#,
1868 r#"OR ("t"."col_1" = 'val_1' AND "t"."col_2" = 'val_2' AND "t"."col_3" = 'val_3' AND "t"."col_4" > 'val_4')"#,
1869 r#"OR ("t"."col_1" = 'val_1' AND "t"."col_2" = 'val_2' AND "t"."col_3" > 'val_3')"#,
1870 r#"OR ("t"."col_1" = 'val_1' AND "t"."col_2" > 'val_2')"#,
1871 r#"OR "t"."col_1" > 'val_1'"#,
1872 r#"ORDER BY "t"."col_1" ASC, "t"."col_2" ASC, "t"."col_3" ASC, "t"."col_4" ASC, "t"."col_5" ASC"#,
1873 ].join(" "))
1874 );
1875
1876 assert_eq!(
1877 DbBackend::Postgres.build(&
1878 Entity::find()
1879 .cursor_by((Column::Col1, Column::Col2, Column::Col3, Column::Col4, Column::Col5, Column::Col6))
1880 .after(("val_1", "val_2", "val_3", "val_4", "val_5", "val_6")).apply_limit().apply_order_by().apply_filters()
1881 .query
1882 ).to_string(),
1883 format!("{base_sql} {}", [
1884 r#"("t"."col_1" = 'val_1' AND "t"."col_2" = 'val_2' AND "t"."col_3" = 'val_3' AND "t"."col_4" = 'val_4' AND "t"."col_5" = 'val_5' AND "t"."col_6" > 'val_6')"#,
1885 r#"OR ("t"."col_1" = 'val_1' AND "t"."col_2" = 'val_2' AND "t"."col_3" = 'val_3' AND "t"."col_4" = 'val_4' AND "t"."col_5" > 'val_5')"#,
1886 r#"OR ("t"."col_1" = 'val_1' AND "t"."col_2" = 'val_2' AND "t"."col_3" = 'val_3' AND "t"."col_4" > 'val_4')"#,
1887 r#"OR ("t"."col_1" = 'val_1' AND "t"."col_2" = 'val_2' AND "t"."col_3" > 'val_3')"#,
1888 r#"OR ("t"."col_1" = 'val_1' AND "t"."col_2" > 'val_2')"#,
1889 r#"OR "t"."col_1" > 'val_1'"#,
1890 r#"ORDER BY "t"."col_1" ASC, "t"."col_2" ASC, "t"."col_3" ASC, "t"."col_4" ASC, "t"."col_5" ASC, "t"."col_6" ASC"#,
1891 ].join(" "))
1892 );
1893

Callers

nothing calls this directly

Calls 1

joinMethod · 0.80

Tested by

no test coverage detected