github.com/mitranim/sqlb@v0.7.2/t_example_misc_test.go (about) 1 package sqlb_test 2 3 import ( 4 "encoding/json" 5 "fmt" 6 7 s "github.com/mitranim/sqlb" 8 ) 9 10 // Copy of `ExampleStrQ_nested` for package-level docs. 11 func Example_composition() { 12 inner := s.StrQ{ 13 `select * from some_table where col0 = :val`, 14 s.Dict{`val`: 10}, 15 } 16 17 outer := s.StrQ{ 18 `select * from (:inner) as _ where col1 = :val`, 19 s.Dict{`inner`: inner, `val`: 20}, 20 } 21 22 fmt.Println(s.Reify(outer)) 23 // Output: 24 // select * from (select * from some_table where col0 = $1) as _ where col1 = $2 [10 20] 25 } 26 27 func ExampleBui_CatchExprs() { 28 bui := s.MakeBui(1024, 16) 29 30 err := bui.CatchExprs( 31 s.Select{`some_table`, s.Ands{true, false}}, 32 ) 33 if err != nil { 34 panic(err) 35 } 36 37 text, args := bui.Reify() 38 fmt.Println(text) 39 fmt.Println(args) 40 41 // Output: 42 // select * from "some_table" where $1 and $2 43 // [true false] 44 } 45 46 func ExampleStr_stringInterpolation() { 47 fmt.Println(s.Reify( 48 s.StrQ{ 49 `select :col from some_table where :col <> :val`, 50 s.Dict{ 51 `col`: s.Str(`some_col`), 52 `val`: `some_val`, 53 }, 54 }, 55 )) 56 // Output: 57 // select some_col from some_table where some_col <> $1 [some_val] 58 } 59 60 func ExampleIdent() { 61 fmt.Println(s.Ident(``)) 62 fmt.Println(s.Ident(`one`)) 63 // Output: 64 // "" 65 // "one" 66 } 67 68 func ExampleIdent_interpolation() { 69 fmt.Println(s.Reify( 70 s.StrQ{ 71 `select :col from some_table where :col <> :val`, 72 s.Dict{ 73 `col`: s.Ident(`some_col`), 74 `val`: `some_val`, 75 }, 76 }, 77 )) 78 // Output: 79 // select "some_col" from some_table where "some_col" <> $1 [some_val] 80 } 81 82 func ExampleIdentifier() { 83 fmt.Println(s.Identifier{`one`}) 84 fmt.Println(s.Identifier{`one`, `two`}) 85 fmt.Println(s.Identifier{`one`, `two`, `three`}) 86 // Output: 87 // "one" 88 // "one"."two" 89 // "one"."two"."three" 90 } 91 92 func ExamplePath() { 93 fmt.Println(s.Path{`one`}) 94 fmt.Println(s.Path{`one`, `two`}) 95 fmt.Println(s.Path{`one`, `two`, `three`}) 96 // Output: 97 // "one" 98 // ("one")."two" 99 // ("one")."two"."three" 100 } 101 102 func ExamplePseudoPath() { 103 fmt.Println(s.PseudoPath{`one`}) 104 fmt.Println(s.PseudoPath{`one`, `two`}) 105 fmt.Println(s.PseudoPath{`one`, `two`, `three`}) 106 // Output: 107 // "one" 108 // "one.two" 109 // "one.two.three" 110 } 111 112 func ExampleAliasedPath() { 113 fmt.Println(s.AliasedPath{`one`}) 114 fmt.Println(s.AliasedPath{`one`, `two`}) 115 fmt.Println(s.AliasedPath{`one`, `two`, `three`}) 116 // Output: 117 // "one" 118 // ("one")."two" as "one.two" 119 // ("one")."two"."three" as "one.two.three" 120 } 121 122 func ExampleExprs() { 123 type Filter struct { 124 Slug string `db:"slug"` 125 } 126 127 fmt.Println(s.Reify( 128 s.Select{`some_table`, Filter{`some_slug`}}, 129 )) 130 // Output: 131 // select * from "some_table" where "slug" = $1 [some_slug] 132 } 133 134 func ExampleAny() { 135 fmt.Println(s.Reify(s.Any{})) 136 fmt.Println(s.Reify(s.Any{[]int{10, 20}})) 137 fmt.Println(s.Reify(s.Any{s.Table{`some_table`}})) 138 139 // Output: 140 // any ($1) [<nil>] 141 // any ($1) [[10 20]] 142 // any (table "some_table") [] 143 } 144 145 func ExampleAssign() { 146 fmt.Println(s.Reify(s.Assign{ 147 `some_col`, 148 `arbitrary_value`, 149 })) 150 151 fmt.Println(s.Reify(s.Assign{ 152 `some_col`, 153 s.Path{`some_table`, `another_col`}, 154 })) 155 156 // Output: 157 // "some_col" = $1 [arbitrary_value] 158 // "some_col" = (("some_table")."another_col") [] 159 } 160 161 func ExampleEq() { 162 fmt.Println(s.Reify(s.Eq{10, 20})) 163 164 fmt.Println(s.Reify(s.Eq{ 165 s.Ident(`some_col`), 166 nil, 167 })) 168 169 fmt.Println(s.Reify(s.Eq{ 170 s.Ident(`some_col`), 171 s.Ident(`another_col`), 172 })) 173 174 fmt.Println(s.Reify(s.Eq{ 175 s.Ident(`some_col`), 176 s.Path{`some_table`, `another_col`}, 177 })) 178 179 // Output: 180 // $1 = $2 [10 20] 181 // ("some_col") is null [] 182 // ("some_col") = ("another_col") [] 183 // ("some_col") = (("some_table")."another_col") [] 184 } 185 186 func ExampleNeq() { 187 fmt.Println(s.Reify(s.Neq{10, 20})) 188 189 fmt.Println(s.Reify(s.Neq{ 190 s.Ident(`some_col`), 191 nil, 192 })) 193 194 fmt.Println(s.Reify(s.Neq{ 195 s.Ident(`some_col`), 196 s.Ident(`another_col`), 197 })) 198 199 fmt.Println(s.Reify(s.Neq{ 200 s.Ident(`some_col`), 201 s.Path{`some_table`, `another_col`}, 202 })) 203 204 // Output: 205 // $1 <> $2 [10 20] 206 // ("some_col") is not null [] 207 // ("some_col") <> ("another_col") [] 208 // ("some_col") <> (("some_table")."another_col") [] 209 } 210 211 func ExampleEqAny() { 212 fmt.Println(s.Reify(s.EqAny{ 213 10, 214 []int{20, 30}, 215 })) 216 217 fmt.Println(s.Reify(s.EqAny{ 218 s.Ident(`some_col`), 219 []int{20, 30}, 220 })) 221 222 fmt.Println(s.Reify(s.EqAny{ 223 s.Ident(`some_col`), 224 s.Table{`some_table`}, 225 })) 226 227 // Output: 228 // $1 = any ($2) [10 [20 30]] 229 // ("some_col") = any ($1) [[20 30]] 230 // ("some_col") = any (table "some_table") [] 231 } 232 233 func ExampleNeqAny() { 234 fmt.Println(s.Reify(s.NeqAny{ 235 10, 236 []int{20, 30}, 237 })) 238 239 fmt.Println(s.Reify(s.NeqAny{ 240 s.Ident(`some_col`), 241 []int{20, 30}, 242 })) 243 244 fmt.Println(s.Reify(s.NeqAny{ 245 s.Ident(`some_col`), 246 s.Table{`some_table`}, 247 })) 248 249 // Output: 250 // $1 <> any ($2) [10 [20 30]] 251 // ("some_col") <> any ($1) [[20 30]] 252 // ("some_col") <> any (table "some_table") [] 253 } 254 255 func ExampleNot() { 256 fmt.Println(s.Reify(s.Not{})) 257 fmt.Println(s.Reify(s.Not{true})) 258 fmt.Println(s.Reify(s.Not{s.Ident(`some_col`)})) 259 // Output: 260 // not $1 [<nil>] 261 // not $1 [true] 262 // not ("some_col") [] 263 } 264 265 func ExampleAnd_struct() { 266 fmt.Println(s.Reify(s.And{struct{}{}})) 267 268 fmt.Println(s.Reify(s.And{struct { 269 Col0 bool `db:"col0"` 270 Col1 any `db:"col1"` 271 Col2 any `db:"col2"` 272 }{ 273 true, 274 nil, 275 s.Call{`some_func`, []int{10}}, 276 }})) 277 278 // Output: 279 // true [] 280 // "col0" = $1 and "col1" is null and "col2" = (some_func ($2)) [true 10] 281 } 282 283 func ExampleAnd_slice() { 284 type list = []any 285 286 fmt.Println(s.Reify(s.And{nil})) 287 fmt.Println(s.Reify(s.And{list{}})) 288 fmt.Println(s.Reify(s.And{list{true, false, s.Ident(`some_col`)}})) 289 290 // Output: 291 // true [] 292 // true [] 293 // $1 and $2 and ("some_col") [true false] 294 } 295 296 func ExampleOr_struct() { 297 fmt.Println(s.Reify(s.Or{struct{}{}})) 298 299 fmt.Println(s.Reify(s.Or{struct { 300 Col0 bool `db:"col0"` 301 Col1 any `db:"col1"` 302 Col2 any `db:"col2"` 303 }{ 304 true, 305 nil, 306 s.Call{`some_func`, []int{10}}, 307 }})) 308 309 // Output: 310 // false [] 311 // "col0" = $1 or "col1" is null or "col2" = (some_func ($2)) [true 10] 312 } 313 314 func ExampleOr_slice() { 315 type list = []any 316 317 fmt.Println(s.Reify(s.Or{nil})) 318 fmt.Println(s.Reify(s.Or{list{}})) 319 fmt.Println(s.Reify(s.Or{list{true, false, s.Ident(`some_col`)}})) 320 321 // Output: 322 // false [] 323 // false [] 324 // $1 or $2 or ("some_col") [true false] 325 } 326 327 func ExampleAnds() { 328 fmt.Println(s.Reify(s.Ands{})) 329 fmt.Println(s.Reify(s.Ands{true, false, s.Ident(`some_col`)})) 330 // Output: 331 // true [] 332 // $1 and $2 and ("some_col") [true false] 333 } 334 335 func ExampleOrs() { 336 fmt.Println(s.Reify(s.Ors{})) 337 fmt.Println(s.Reify(s.Ors{true, false, s.Ident(`some_col`)})) 338 // Output: 339 // false [] 340 // $1 or $2 or ("some_col") [true false] 341 } 342 343 func ExampleCols_nonStruct() { 344 fmt.Println(s.Cols{}) 345 fmt.Println(s.Cols{(*int)(nil)}) 346 fmt.Println(s.Cols{(*[]string)(nil)}) 347 // Output: 348 // * 349 // * 350 // * 351 } 352 353 func ExampleCols_struct() { 354 type Internal struct { 355 Id string `db:"id"` 356 Name string `db:"name"` 357 } 358 359 type External struct { 360 Id string `db:"id"` 361 Name string `db:"name"` 362 Internal Internal `db:"internal"` 363 } 364 365 fmt.Println(s.Cols{(*External)(nil)}) 366 // Output: 367 // "id", "name", "internal" 368 } 369 370 func ExampleColsDeep_nonStruct() { 371 fmt.Println(s.ColsDeep{}) 372 fmt.Println(s.ColsDeep{(*int)(nil)}) 373 fmt.Println(s.ColsDeep{(*[]string)(nil)}) 374 // Output: 375 // * 376 // * 377 // * 378 } 379 380 func ExampleColsDeep_struct() { 381 type Internal struct { 382 Id string `db:"id"` 383 Name string `db:"name"` 384 } 385 386 type External struct { 387 Id string `db:"id"` 388 Name string `db:"name"` 389 Internal Internal `db:"internal"` 390 } 391 392 fmt.Println(s.ColsDeep{(*External)(nil)}) 393 // Output: 394 // "id", "name", ("internal")."id" as "internal.id", ("internal")."name" as "internal.name" 395 } 396 397 func ExampleStructValues() { 398 fmt.Println(s.Reify(s.StructValues{struct { 399 Col0 bool `db:"col0"` 400 Col1 any `db:"col1"` 401 Col2 any `db:"col2"` 402 }{ 403 true, 404 nil, 405 s.Call{`some_func`, []int{10}}, 406 }})) 407 // Output: 408 // $1, $2, (some_func ($3)) [true <nil> 10] 409 } 410 411 func ExampleStructInsert_empty() { 412 fmt.Println(s.StructInsert{}) 413 // Output: 414 // default values 415 } 416 417 func ExampleStructInsert_nonEmpty() { 418 fmt.Println(s.Reify(s.StructInsert{struct { 419 Col0 bool `db:"col0"` 420 Col1 any `db:"col1"` 421 Col2 any `db:"col2"` 422 }{ 423 true, 424 nil, 425 s.Call{`some_func`, []int{10}}, 426 }})) 427 // Output: 428 // ("col0", "col1", "col2") values ($1, $2, (some_func ($3))) [true <nil> 10] 429 } 430 431 func ExampleStructsInsert_empty() { 432 fmt.Println(s.StructsInsertOf[any]()) 433 // Output: 434 } 435 436 func ExampleStructsInsert_nonEmpty() { 437 type Row struct { 438 Col0 bool `db:"col0"` 439 Col1 int64 `db:"col1"` 440 Col2 string `db:"col2"` 441 } 442 443 fmt.Println(s.Reify(s.StructsInsertOf( 444 Row{true, 10, `one`}, 445 Row{false, 20, `two`}, 446 ))) 447 // Output: 448 // ("col0", "col1", "col2") values ($1, $2, $3), ($4, $5, $6) [true 10 one false 20 two] 449 } 450 451 func ExampleStructAssign() { 452 fmt.Println(s.Reify(s.StructAssign{struct { 453 Col0 bool `db:"col0"` 454 Col1 any `db:"col1"` 455 Col2 any `db:"col2"` 456 }{ 457 true, 458 nil, 459 s.Call{`some_func`, []int{10}}, 460 }})) 461 // Output: 462 // "col0" = $1, "col1" = $2, "col2" = (some_func ($3)) [true <nil> 10] 463 } 464 465 func ExampleSelectCols_asIs() { 466 fmt.Println(s.SelectCols{s.Table{`some_table`}, nil}) 467 // Output: 468 // table "some_table" 469 } 470 471 func ExampleSelectCols_cols() { 472 type SomeStruct struct { 473 Col0 string `db:"col0"` 474 Col1 string `db:"col1"` 475 Col2 string `db:"-"` 476 } 477 478 fmt.Println(s.SelectCols{s.Table{`some_table`}, (*SomeStruct)(nil)}) 479 // Output: 480 // with _ as (table "some_table") select "col0", "col1" from _ 481 } 482 483 func ExampleSelectColsDeep_asIs() { 484 fmt.Println(s.SelectColsDeep{s.Table{`some_table`}, nil}) 485 // Output: 486 // table "some_table" 487 } 488 489 func ExampleSelectColsDeep_cols() { 490 type SomeStruct struct { 491 Outer string `db:"outer"` 492 Inner struct { 493 Name string `db:"name"` 494 } `db:"inner"` 495 } 496 497 fmt.Println(s.SelectColsDeep{s.Table{`some_table`}, (*SomeStruct)(nil)}) 498 // Output: 499 // with _ as (table "some_table") select "outer", ("inner")."name" as "inner.name" from _ 500 } 501 502 func ExampleSelect_unfiltered() { 503 fmt.Println(s.Reify(s.Select{`some_table`, nil})) 504 // Output: 505 // select * from "some_table" [] 506 } 507 508 func ExampleSelect_filtered() { 509 type Filter struct { 510 Col0 int64 `db:"col0"` 511 Col1 int64 `db:"col1"` 512 } 513 514 fmt.Println(s.Reify(s.Select{`some_table`, Filter{10, 20}})) 515 // Output: 516 // select * from "some_table" where "col0" = $1 and "col1" = $2 [10 20] 517 } 518 519 func ExampleInsert_empty() { 520 fmt.Println(s.Reify(s.Insert{`some_table`, nil})) 521 // Output: 522 // insert into "some_table" default values returning * [] 523 } 524 525 func ExampleInsert_nonEmpty() { 526 type Fields struct { 527 Col0 int64 `db:"col0"` 528 Col1 int64 `db:"col1"` 529 } 530 531 fmt.Println(s.Reify(s.Insert{`some_table`, Fields{10, 20}})) 532 533 // Output: 534 // insert into "some_table" ("col0", "col1") values ($1, $2) returning * [10 20] 535 } 536 537 func ExampleUpdate() { 538 type Filter struct { 539 Col0 int64 `db:"col0"` 540 Col1 int64 `db:"col1"` 541 } 542 543 type Fields struct { 544 Col2 int64 `db:"col2"` 545 Col3 int64 `db:"col3"` 546 } 547 548 fmt.Println(s.Reify( 549 s.Update{`some_table`, Filter{10, 20}, Fields{30, 40}}, 550 )) 551 552 // Output: 553 // update "some_table" set "col2" = $1, "col3" = $2 where "col0" = $3 and "col1" = $4 returning * [30 40 10 20] 554 } 555 556 func ExampleDelete_unfiltered() { 557 fmt.Println(s.Reify(s.Delete{`some_table`, nil})) 558 // Output: 559 // delete from "some_table" where null returning * [] 560 } 561 562 func ExampleDelete_filtered() { 563 type Filter struct { 564 Col0 int64 `db:"col0"` 565 Col1 int64 `db:"col1"` 566 } 567 568 fmt.Println(s.Reify(s.Delete{`some_table`, Filter{10, 20}})) 569 570 // Output: 571 // delete from "some_table" where "col0" = $1 and "col1" = $2 returning * [10 20] 572 } 573 574 func ExampleSelectCount() { 575 fmt.Println( 576 s.SelectCount{s.Table{`some_table`}}, 577 ) 578 // Output: 579 // with _ as (table "some_table") select count(*) from _ 580 } 581 582 func ExampleCall_empty() { 583 fmt.Println(s.Call{`some_func`, nil}) 584 // Output: 585 // some_func () 586 } 587 588 func ExampleCall_arguments() { 589 fmt.Println(s.Reify(s.Call{`some_func`, []int{10, 20, 30}})) 590 // Output: 591 // some_func ($1, $2, $3) [10 20 30] 592 } 593 594 func ExampleCall_subExpression() { 595 fmt.Println(s.Call{`exists`, s.Table{`some_table`}}) 596 // Output: 597 // exists (table "some_table") 598 } 599 600 func ExampleCall_subExpressions() { 601 fmt.Println(s.Call{`some_func`, []s.Ident{`one`, `two`}}) 602 // Output: 603 // some_func (("one"), ("two")) 604 } 605 606 func ExampleRowNumberOver_empty() { 607 fmt.Println(s.RowNumberOver{}) 608 // Output: 609 // 0 610 } 611 612 func ExampleRowNumberOver_nonEmpty() { 613 fmt.Println(s.RowNumberOver{s.Ords{s.OrdDesc{`some_col`}}}) 614 // Output: 615 // row_number() over (order by "some_col" desc) 616 } 617 618 func ExampleListQ() { 619 fmt.Println(s.Reify( 620 s.ListQ(` 621 select * from some_table where col_one = $1 and col_two = $2 622 `, 10, 20), 623 )) 624 // Output: 625 // select * from some_table where col_one = $1 and col_two = $2 [10 20] 626 } 627 628 func ExampleDictQ() { 629 fmt.Println(s.Reify( 630 s.DictQ(` 631 select * from some_table where col_one = :one and col_two = :two 632 `, map[string]any{ 633 `one`: 10, 634 `two`: 20, 635 }), 636 )) 637 // Output: 638 // select * from some_table where col_one = $1 and col_two = $2 [10 20] 639 } 640 641 func ExampleStrQ_empty() { 642 fmt.Println(s.Reify(s.StrQ{})) 643 // Output: 644 // [] 645 } 646 647 func ExampleStrQ_simple() { 648 fmt.Println(s.Reify( 649 s.StrQ{ 650 `select * from some_table where col_one = :one and col_two = :two`, 651 s.Dict{ 652 `one`: 10, 653 `two`: 20, 654 }, 655 }, 656 )) 657 // Output: 658 // select * from some_table where col_one = $1 and col_two = $2 [10 20] 659 } 660 661 func ExampleStrQ_structs() { 662 type Output struct { 663 Col0 string `db:"col0"` 664 Col1 string `db:"col1"` 665 } 666 667 type Filter struct { 668 Col2 int64 `db:"col2"` 669 Col3 int64 `db:"col3"` 670 } 671 672 fmt.Println(s.Reify( 673 s.StrQ{ 674 `select :cols from some_table where :filter`, 675 s.Dict{ 676 `cols`: s.Cols{(*Output)(nil)}, 677 `filter`: s.And{Filter{10, 20}}, 678 }, 679 }, 680 )) 681 // Output: 682 // select "col0", "col1" from some_table where "col2" = $1 and "col3" = $2 [10 20] 683 } 684 685 func ExampleStrQ_structInput() { 686 type Output struct { 687 Col0 string `db:"col0"` 688 Col1 string `db:"col1"` 689 } 690 691 type Filter struct { 692 Col2 int64 `db:"col2"` 693 Col3 int64 `db:"col3"` 694 } 695 696 type Input struct { 697 Cols s.Cols 698 Filter s.And 699 } 700 701 fmt.Println(s.Reify( 702 s.StructQ(` 703 select :Cols from some_table where :Filter 704 `, Input{ 705 s.Cols{(*Output)(nil)}, 706 s.And{Filter{10, 20}}, 707 }), 708 )) 709 // Output: 710 // select "col0", "col1" from some_table where "col2" = $1 and "col3" = $2 [10 20] 711 } 712 713 func ExampleStrQ_nested() { 714 inner := s.StrQ{ 715 `select * from some_table where col0 = :val`, 716 s.Dict{`val`: 10}, 717 } 718 719 outer := s.StrQ{ 720 `select * from (:inner) as _ where col1 = :val`, 721 s.Dict{`inner`: inner, `val`: 20}, 722 } 723 724 fmt.Println(s.Reify(outer)) 725 // Output: 726 // select * from (select * from some_table where col0 = $1) as _ where col1 = $2 [10 20] 727 } 728 729 func ExampleOrds_empty() { 730 fmt.Println(s.Ords{}) 731 // Output: 732 } 733 734 func ExampleOrds_manual() { 735 fmt.Println(s.Ords{ 736 s.OrdDesc{`col0`}, 737 s.Str(`random() asc`), 738 }) 739 // Output: 740 // order by "col0" desc, random() asc 741 } 742 743 func ExampleOrds_OrdsParser() { 744 type SomeStruct struct { 745 Col0 string `json:"jsonField0" db:"dbCol0"` 746 Col1 string `json:"jsonField1" db:"dbCol1"` 747 } 748 749 var ords s.Ords 750 err := ords.OrdsParser((*SomeStruct)(nil)).ParseSlice([]string{ 751 `jsonField0 asc`, 752 `jsonField1 desc nulls last`, 753 }) 754 if err != nil { 755 panic(err) 756 } 757 758 fmt.Printf("%#v\n\n", ords) 759 fmt.Println(ords) 760 // Output: 761 // sqlb.Ords{sqlb.OrdAsc{"dbCol0"}, sqlb.OrdDescNullsLast{"dbCol1"}} 762 // 763 // order by "dbCol0" asc, "dbCol1" desc nulls last 764 } 765 766 func ExampleParserOrds_ParseSlice() { 767 type SomeStruct struct { 768 Col0 string `json:"jsonField0" db:"dbCol0"` 769 Col1 string `json:"jsonField1" db:"dbCol1"` 770 } 771 772 var par s.ParserOrds 773 par.OrType((*SomeStruct)(nil)) 774 775 err := par.ParseSlice([]string{`jsonField0 asc`, `jsonField1 desc nulls last`}) 776 if err != nil { 777 panic(err) 778 } 779 780 fmt.Printf("%#v\n\n", par.Ords) 781 fmt.Println(par.Ords) 782 // Output: 783 // sqlb.Ords{sqlb.OrdAsc{"dbCol0"}, sqlb.OrdDescNullsLast{"dbCol1"}} 784 // 785 // order by "dbCol0" asc, "dbCol1" desc nulls last 786 } 787 788 func ExampleParserOrds_UnmarshalJSON() { 789 type SomeStruct struct { 790 Col0 string `json:"jsonField0" db:"dbCol0"` 791 Col1 string `json:"jsonField1" db:"dbCol1"` 792 } 793 794 var par s.ParserOrds 795 par.OrType((*SomeStruct)(nil)) 796 797 err := json.Unmarshal( 798 []byte(`["jsonField0 asc", "jsonField1 desc nulls last"]`), 799 &par, 800 ) 801 if err != nil { 802 panic(err) 803 } 804 805 fmt.Printf("%#v\n\n", par.Ords) 806 fmt.Println(par.Ords) 807 // Output: 808 // sqlb.Ords{sqlb.OrdAsc{"dbCol0"}, sqlb.OrdDescNullsLast{"dbCol1"}} 809 // 810 // order by "dbCol0" asc, "dbCol1" desc nulls last 811 } 812 813 func ExampleLimitUint() { 814 fmt.Println(s.Reify( 815 s.Exprs{s.Select{`some_table`, nil}, s.LimitUint(10)}, 816 )) 817 // Output: 818 // select * from "some_table" limit 10 [] 819 } 820 821 func ExampleOffsetUint() { 822 fmt.Println(s.Reify( 823 s.Exprs{s.Select{`some_table`, nil}, s.OffsetUint(10)}, 824 )) 825 // Output: 826 // select * from "some_table" offset 10 [] 827 }