@budibase/server 1.0.80-alpha.1 → 1.0.80-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/builder/assets/{index.c0b657be.js → index.db9b03fd.js} +1 -1
  2. package/builder/index.html +1 -1
  3. package/coverage/clover.xml +103 -99
  4. package/coverage/coverage-final.json +1 -1
  5. package/coverage/lcov-report/api/controllers/analytics.js.html +1 -1
  6. package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
  7. package/coverage/lcov-report/api/controllers/application.js.html +1 -1
  8. package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
  9. package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
  10. package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
  11. package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
  12. package/coverage/lcov-report/api/controllers/component.js.html +1 -1
  13. package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
  14. package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
  15. package/coverage/lcov-report/api/controllers/index.html +1 -1
  16. package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
  17. package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
  18. package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
  19. package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
  20. package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
  21. package/coverage/lcov-report/api/controllers/query/index.html +1 -1
  22. package/coverage/lcov-report/api/controllers/query/index.js.html +1 -1
  23. package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
  24. package/coverage/lcov-report/api/controllers/role.js.html +1 -1
  25. package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
  26. package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
  27. package/coverage/lcov-report/api/controllers/row/index.html +1 -1
  28. package/coverage/lcov-report/api/controllers/row/index.js.html +1 -1
  29. package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
  30. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
  31. package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
  32. package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
  33. package/coverage/lcov-report/api/controllers/screen.js.html +1 -1
  34. package/coverage/lcov-report/api/controllers/script.js.html +1 -1
  35. package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +1 -1
  36. package/coverage/lcov-report/api/controllers/table/external.js.html +51 -9
  37. package/coverage/lcov-report/api/controllers/table/index.html +14 -14
  38. package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
  39. package/coverage/lcov-report/api/controllers/table/internal.js.html +1 -1
  40. package/coverage/lcov-report/api/controllers/table/utils.js.html +1 -1
  41. package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
  42. package/coverage/lcov-report/api/controllers/user.js.html +1 -1
  43. package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
  44. package/coverage/lcov-report/api/controllers/view/index.html +1 -1
  45. package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
  46. package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
  47. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
  48. package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
  49. package/coverage/lcov-report/api/index.html +1 -1
  50. package/coverage/lcov-report/api/index.js.html +1 -1
  51. package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
  52. package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
  53. package/coverage/lcov-report/api/routes/application.js.html +1 -1
  54. package/coverage/lcov-report/api/routes/auth.js.html +1 -1
  55. package/coverage/lcov-report/api/routes/automation.js.html +1 -1
  56. package/coverage/lcov-report/api/routes/backup.js.html +1 -1
  57. package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
  58. package/coverage/lcov-report/api/routes/component.js.html +1 -1
  59. package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
  60. package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
  61. package/coverage/lcov-report/api/routes/dev.js.html +1 -1
  62. package/coverage/lcov-report/api/routes/index.html +1 -1
  63. package/coverage/lcov-report/api/routes/index.js.html +1 -1
  64. package/coverage/lcov-report/api/routes/integration.js.html +1 -1
  65. package/coverage/lcov-report/api/routes/layout.js.html +1 -1
  66. package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
  67. package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
  68. package/coverage/lcov-report/api/routes/permission.js.html +1 -1
  69. package/coverage/lcov-report/api/routes/query.js.html +1 -1
  70. package/coverage/lcov-report/api/routes/role.js.html +1 -1
  71. package/coverage/lcov-report/api/routes/routing.js.html +1 -1
  72. package/coverage/lcov-report/api/routes/row.js.html +1 -1
  73. package/coverage/lcov-report/api/routes/screen.js.html +1 -1
  74. package/coverage/lcov-report/api/routes/script.js.html +1 -1
  75. package/coverage/lcov-report/api/routes/static.js.html +1 -1
  76. package/coverage/lcov-report/api/routes/table.js.html +1 -1
  77. package/coverage/lcov-report/api/routes/templates.js.html +1 -1
  78. package/coverage/lcov-report/api/routes/user.js.html +1 -1
  79. package/coverage/lcov-report/api/routes/utils/index.html +1 -1
  80. package/coverage/lcov-report/api/routes/utils/validators.js.html +1 -1
  81. package/coverage/lcov-report/api/routes/view.js.html +1 -1
  82. package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
  83. package/coverage/lcov-report/automations/actions.js.html +1 -1
  84. package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
  85. package/coverage/lcov-report/automations/bullboard.js.html +1 -1
  86. package/coverage/lcov-report/automations/index.html +1 -1
  87. package/coverage/lcov-report/automations/index.js.html +1 -1
  88. package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
  89. package/coverage/lcov-report/automations/steps/createRow.js.html +1 -1
  90. package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
  91. package/coverage/lcov-report/automations/steps/deleteRow.js.html +1 -1
  92. package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
  93. package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
  94. package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
  95. package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
  96. package/coverage/lcov-report/automations/steps/index.html +1 -1
  97. package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
  98. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
  99. package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
  100. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
  101. package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
  102. package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
  103. package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
  104. package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
  105. package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
  106. package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
  107. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
  108. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  109. package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
  110. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
  111. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
  112. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
  113. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
  114. package/coverage/lcov-report/automations/triggers.js.html +1 -1
  115. package/coverage/lcov-report/automations/utils.js.html +1 -1
  116. package/coverage/lcov-report/constants/index.html +1 -1
  117. package/coverage/lcov-report/constants/index.js.html +1 -1
  118. package/coverage/lcov-report/constants/layouts.js.html +1 -1
  119. package/coverage/lcov-report/constants/screens.js.html +1 -1
  120. package/coverage/lcov-report/db/client.js.html +1 -1
  121. package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
  122. package/coverage/lcov-report/db/index.html +1 -1
  123. package/coverage/lcov-report/db/index.js.html +1 -1
  124. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
  125. package/coverage/lcov-report/db/linkedRows/index.html +1 -1
  126. package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
  127. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
  128. package/coverage/lcov-report/db/newid.js.html +1 -1
  129. package/coverage/lcov-report/db/utils.js.html +1 -1
  130. package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
  131. package/coverage/lcov-report/events/index.html +1 -1
  132. package/coverage/lcov-report/events/index.js.html +1 -1
  133. package/coverage/lcov-report/events/utils.js.html +1 -1
  134. package/coverage/lcov-report/index.html +14 -14
  135. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  136. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  137. package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
  138. package/coverage/lcov-report/middleware/authorized.js.html +1 -1
  139. package/coverage/lcov-report/middleware/builder.js.html +1 -1
  140. package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
  141. package/coverage/lcov-report/middleware/index.html +1 -1
  142. package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
  143. package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
  144. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  145. package/coverage/lcov-report/middleware/usageQuota.js.html +1 -1
  146. package/coverage/lcov-report/middleware/utils.js.html +1 -1
  147. package/coverage/lcov-report/threads/automation.js.html +1 -1
  148. package/coverage/lcov-report/threads/index.html +1 -1
  149. package/coverage/lcov-report/threads/index.js.html +1 -1
  150. package/coverage/lcov-report/threads/query.js.html +1 -1
  151. package/coverage/lcov-report/threads/utils.js.html +1 -1
  152. package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
  153. package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
  154. package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
  155. package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
  156. package/coverage/lcov-report/utilities/global.js.html +1 -1
  157. package/coverage/lcov-report/utilities/index.html +1 -1
  158. package/coverage/lcov-report/utilities/index.js.html +1 -1
  159. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +1 -1
  160. package/coverage/lcov-report/utilities/queue/index.html +1 -1
  161. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  162. package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
  163. package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
  164. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
  165. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
  166. package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
  167. package/coverage/lcov-report/utilities/security.js.html +1 -1
  168. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  169. package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
  170. package/coverage/lcov-report/utilities/usageQuota/index.js.html +1 -1
  171. package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
  172. package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
  173. package/coverage/lcov-report/utilities/users.js.html +1 -1
  174. package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
  175. package/coverage/lcov.info +169 -162
  176. package/dist/api/controllers/table/external.js +8 -2
  177. package/dist/integrations/base/sql.js +16 -1
  178. package/dist/integrations/base/sqlTable.js +21 -9
  179. package/dist/integrations/microsoftSqlServer.js +28 -17
  180. package/dist/integrations/utils.js +32 -15
  181. package/dist/package.json +4 -4
  182. package/dist/tsconfig.tsbuildinfo +1 -1
  183. package/package.json +5 -5
  184. package/scripts/integrations/mssql/data/setup.sql +18 -1
  185. package/scripts/integrations/postgres/init.sql +6 -0
  186. package/specs/generate.js +13 -2
  187. package/specs/openapi.json +13 -3
  188. package/specs/openapi.yaml +10 -2
  189. package/src/api/controllers/table/external.js +16 -2
  190. package/src/definitions/datasource.ts +7 -0
  191. package/src/integrations/base/sql.ts +16 -1
  192. package/src/integrations/base/sqlTable.ts +35 -13
  193. package/src/integrations/microsoftSqlServer.ts +52 -32
  194. package/src/integrations/utils.ts +43 -15
@@ -3555,19 +3555,19 @@ end_of_record
3555
3555
  TN:
3556
3556
  SF:src/api/controllers/table/external.js
3557
3557
  FN:23,makeTableRequest
3558
- FN:47,cleanupRelationships
3559
- FN:56,(anonymous_2)
3560
- FN:76,getDatasourceId
3561
- FN:86,otherRelationshipType
3562
- FN:95,generateManyLinkSchema
3563
- FN:123,generateLinkSchema
3564
- FN:134,generateRelatedSchema
3565
- FN:157,isRelationshipSetup
3566
- FN:161,(anonymous_9)
3567
- FN:198,(anonymous_10)
3568
- FN:256,(anonymous_11)
3569
- FN:268,(anonymous_12)
3570
- FN:290,(anonymous_13)
3558
+ FN:51,cleanupRelationships
3559
+ FN:60,(anonymous_2)
3560
+ FN:80,getDatasourceId
3561
+ FN:90,otherRelationshipType
3562
+ FN:99,generateManyLinkSchema
3563
+ FN:127,generateLinkSchema
3564
+ FN:138,generateRelatedSchema
3565
+ FN:161,isRelationshipSetup
3566
+ FN:165,(anonymous_9)
3567
+ FN:203,(anonymous_10)
3568
+ FN:268,(anonymous_11)
3569
+ FN:282,(anonymous_12)
3570
+ FN:304,(anonymous_13)
3571
3571
  FNF:14
3572
3572
  FNH:0
3573
3573
  FNDA:0,makeTableRequest
@@ -3592,211 +3592,218 @@ DA:18,40
3592
3592
  DA:19,40
3593
3593
  DA:20,40
3594
3594
  DA:21,40
3595
- DA:30,0
3596
- DA:41,0
3595
+ DA:31,0
3597
3596
  DA:42,0
3598
- DA:44,0
3597
+ DA:43,0
3598
+ DA:45,0
3599
+ DA:46,0
3599
3600
  DA:48,0
3600
- DA:50,0
3601
- DA:51,0
3601
+ DA:52,0
3602
+ DA:54,0
3602
3603
  DA:55,0
3603
- DA:56,0
3604
- DA:58,0
3605
3604
  DA:59,0
3606
3605
  DA:60,0
3607
3606
  DA:62,0
3608
- DA:65,0
3607
+ DA:63,0
3608
+ DA:64,0
3609
+ DA:66,0
3609
3610
  DA:69,0
3610
- DA:77,0
3611
- DA:78,0
3612
- DA:80,0
3611
+ DA:73,0
3613
3612
  DA:81,0
3614
- DA:83,0
3613
+ DA:82,0
3614
+ DA:84,0
3615
+ DA:85,0
3615
3616
  DA:87,0
3616
- DA:88,0
3617
- DA:90,0
3618
- DA:96,0
3619
- DA:97,0
3620
- DA:98,0
3617
+ DA:91,0
3618
+ DA:92,0
3619
+ DA:94,0
3621
3620
  DA:100,0
3622
- DA:116,0
3623
- DA:117,0
3624
- DA:118,0
3625
- DA:119,0
3621
+ DA:101,0
3622
+ DA:102,0
3623
+ DA:104,0
3626
3624
  DA:120,0
3625
+ DA:121,0
3626
+ DA:122,0
3627
+ DA:123,0
3627
3628
  DA:124,0
3628
- DA:125,0
3629
- DA:127,0
3630
3629
  DA:128,0
3631
3630
  DA:129,0
3632
- DA:130,0
3633
3631
  DA:131,0
3634
- DA:136,0
3635
- DA:138,0
3636
- DA:139,0
3632
+ DA:132,0
3633
+ DA:133,0
3634
+ DA:134,0
3635
+ DA:135,0
3637
3636
  DA:140,0
3638
- DA:145,0
3639
- DA:146,0
3640
- DA:147,0
3637
+ DA:142,0
3638
+ DA:143,0
3639
+ DA:144,0
3641
3640
  DA:149,0
3642
- DA:152,0
3641
+ DA:150,0
3642
+ DA:151,0
3643
3643
  DA:153,0
3644
- DA:154,0
3644
+ DA:156,0
3645
+ DA:157,0
3645
3646
  DA:158,0
3646
- DA:161,40
3647
3647
  DA:162,0
3648
- DA:164,0
3649
- DA:165,0
3648
+ DA:165,40
3649
+ DA:166,0
3650
3650
  DA:167,0
3651
- DA:168,0
3651
+ DA:169,0
3652
3652
  DA:170,0
3653
- DA:177,0
3654
- DA:178,0
3655
- DA:181,0
3653
+ DA:172,0
3654
+ DA:173,0
3655
+ DA:175,0
3656
3656
  DA:182,0
3657
- DA:185,0
3657
+ DA:183,0
3658
3658
  DA:186,0
3659
3659
  DA:187,0
3660
- DA:188,0
3661
3660
  DA:190,0
3661
+ DA:191,0
3662
+ DA:192,0
3662
3663
  DA:193,0
3663
- DA:194,0
3664
3664
  DA:195,0
3665
- DA:197,0
3666
3665
  DA:198,0
3666
+ DA:199,0
3667
3667
  DA:200,0
3668
- DA:201,0
3669
3668
  DA:202,0
3670
3669
  DA:203,0
3671
- DA:209,0
3672
- DA:210,0
3673
- DA:212,0
3674
- DA:213,0
3675
- DA:216,0
3670
+ DA:205,0
3671
+ DA:206,0
3672
+ DA:207,0
3673
+ DA:208,0
3674
+ DA:214,0
3675
+ DA:215,0
3676
3676
  DA:217,0
3677
- DA:223,0
3678
- DA:224,0
3679
- DA:225,0
3680
- DA:227,0
3677
+ DA:218,0
3678
+ DA:221,0
3679
+ DA:222,0
3681
3680
  DA:228,0
3682
- DA:231,0
3681
+ DA:229,0
3682
+ DA:230,0
3683
3683
  DA:232,0
3684
- DA:235,0
3684
+ DA:233,0
3685
3685
  DA:236,0
3686
- DA:239,0
3686
+ DA:237,0
3687
+ DA:240,0
3687
3688
  DA:241,0
3688
3689
  DA:244,0
3689
3690
  DA:246,0
3690
- DA:247,0
3691
- DA:248,0
3692
- DA:251,0
3693
- DA:255,0
3694
- DA:256,0
3695
- DA:257,0
3696
- DA:262,0
3691
+ DA:249,0
3692
+ DA:258,0
3693
+ DA:259,0
3694
+ DA:260,0
3697
3695
  DA:263,0
3698
- DA:265,0
3699
- DA:268,40
3696
+ DA:267,0
3697
+ DA:268,0
3700
3698
  DA:269,0
3701
- DA:270,0
3702
- DA:271,0
3703
- DA:273,0
3704
- DA:275,0
3699
+ DA:274,0
3705
3700
  DA:276,0
3706
3701
  DA:277,0
3707
3702
  DA:279,0
3708
- DA:280,0
3709
- DA:282,0
3703
+ DA:282,40
3704
+ DA:283,0
3710
3705
  DA:284,0
3711
3706
  DA:285,0
3712
3707
  DA:287,0
3713
- DA:290,40
3708
+ DA:289,0
3709
+ DA:290,0
3714
3710
  DA:291,0
3715
- DA:292,0
3716
3711
  DA:293,0
3717
3712
  DA:294,0
3718
3713
  DA:296,0
3719
- DA:300,0
3720
- DA:303,0
3721
- LF:134
3714
+ DA:298,0
3715
+ DA:299,0
3716
+ DA:301,0
3717
+ DA:304,40
3718
+ DA:305,0
3719
+ DA:306,0
3720
+ DA:307,0
3721
+ DA:308,0
3722
+ DA:310,0
3723
+ DA:314,0
3724
+ DA:317,0
3725
+ LF:138
3722
3726
  LH:11
3723
3727
  BRDA:28,0,0,0
3724
- BRDA:41,1,0,0
3725
- BRDA:41,1,1,0
3726
- BRDA:47,2,0,0
3727
- BRDA:48,3,0,0
3728
- BRDA:48,3,1,0
3728
+ BRDA:29,1,0,0
3729
+ BRDA:42,2,0,0
3730
+ BRDA:42,2,1,0
3731
+ BRDA:45,3,0,0
3732
+ BRDA:45,3,1,0
3729
3733
  BRDA:51,4,0,0
3730
- BRDA:51,4,1,0
3731
3734
  BRDA:52,5,0,0
3732
3735
  BRDA:52,5,1,0
3733
- BRDA:52,5,2,0
3734
- BRDA:59,6,0,0
3735
- BRDA:59,6,1,0
3736
- BRDA:59,7,0,0
3737
- BRDA:59,7,1,0
3738
- BRDA:65,8,0,0
3739
- BRDA:65,8,1,0
3740
- BRDA:66,9,0,0
3741
- BRDA:66,9,1,0
3742
- BRDA:77,10,0,0
3743
- BRDA:77,10,1,0
3744
- BRDA:80,11,0,0
3745
- BRDA:80,11,1,0
3746
- BRDA:87,12,0,0
3747
- BRDA:87,12,1,0
3748
- BRDA:90,13,0,0
3749
- BRDA:90,13,1,0
3750
- BRDA:125,14,0,0
3751
- BRDA:125,14,1,0
3752
- BRDA:129,15,0,0
3753
- BRDA:129,15,1,0
3754
- BRDA:130,16,0,0
3755
- BRDA:130,16,1,0
3756
- BRDA:138,17,0,0
3757
- BRDA:138,17,1,0
3758
- BRDA:158,18,0,0
3759
- BRDA:158,18,1,0
3760
- BRDA:167,19,0,0
3761
- BRDA:167,19,1,0
3762
- BRDA:177,20,0,0
3763
- BRDA:177,20,1,0
3764
- BRDA:177,21,0,0
3765
- BRDA:177,21,1,0
3766
- BRDA:181,22,0,0
3767
- BRDA:181,22,1,0
3768
- BRDA:194,23,0,0
3769
- BRDA:194,23,1,0
3770
- BRDA:194,24,0,0
3771
- BRDA:194,24,1,0
3772
- BRDA:202,25,0,0
3773
- BRDA:202,25,1,0
3774
- BRDA:209,26,0,0
3775
- BRDA:209,26,1,0
3776
- BRDA:216,27,0,0
3777
- BRDA:216,27,1,0
3778
- BRDA:224,28,0,0
3779
- BRDA:224,28,1,0
3780
- BRDA:227,29,0,0
3781
- BRDA:227,29,1,0
3782
- BRDA:231,30,0,0
3783
- BRDA:231,30,1,0
3784
- BRDA:241,31,0,0
3785
- BRDA:241,31,1,0
3786
- BRDA:248,32,0,0
3787
- BRDA:248,32,1,0
3788
- BRDA:255,33,0,0
3789
- BRDA:255,33,1,0
3790
- BRDA:270,34,0,0
3791
- BRDA:270,34,1,0
3792
- BRDA:270,35,0,0
3793
- BRDA:270,35,1,0
3794
- BRDA:293,36,0,0
3795
- BRDA:293,36,1,0
3796
- BRDA:293,37,0,0
3797
- BRDA:293,37,1,0
3798
- BRDA:293,37,2,0
3799
- BRF:76
3736
+ BRDA:55,6,0,0
3737
+ BRDA:55,6,1,0
3738
+ BRDA:56,7,0,0
3739
+ BRDA:56,7,1,0
3740
+ BRDA:56,7,2,0
3741
+ BRDA:63,8,0,0
3742
+ BRDA:63,8,1,0
3743
+ BRDA:63,9,0,0
3744
+ BRDA:63,9,1,0
3745
+ BRDA:69,10,0,0
3746
+ BRDA:69,10,1,0
3747
+ BRDA:70,11,0,0
3748
+ BRDA:70,11,1,0
3749
+ BRDA:81,12,0,0
3750
+ BRDA:81,12,1,0
3751
+ BRDA:84,13,0,0
3752
+ BRDA:84,13,1,0
3753
+ BRDA:91,14,0,0
3754
+ BRDA:91,14,1,0
3755
+ BRDA:94,15,0,0
3756
+ BRDA:94,15,1,0
3757
+ BRDA:129,16,0,0
3758
+ BRDA:129,16,1,0
3759
+ BRDA:133,17,0,0
3760
+ BRDA:133,17,1,0
3761
+ BRDA:134,18,0,0
3762
+ BRDA:134,18,1,0
3763
+ BRDA:142,19,0,0
3764
+ BRDA:142,19,1,0
3765
+ BRDA:162,20,0,0
3766
+ BRDA:162,20,1,0
3767
+ BRDA:172,21,0,0
3768
+ BRDA:172,21,1,0
3769
+ BRDA:182,22,0,0
3770
+ BRDA:182,22,1,0
3771
+ BRDA:182,23,0,0
3772
+ BRDA:182,23,1,0
3773
+ BRDA:186,24,0,0
3774
+ BRDA:186,24,1,0
3775
+ BRDA:199,25,0,0
3776
+ BRDA:199,25,1,0
3777
+ BRDA:199,26,0,0
3778
+ BRDA:199,26,1,0
3779
+ BRDA:207,27,0,0
3780
+ BRDA:207,27,1,0
3781
+ BRDA:214,28,0,0
3782
+ BRDA:214,28,1,0
3783
+ BRDA:221,29,0,0
3784
+ BRDA:221,29,1,0
3785
+ BRDA:229,30,0,0
3786
+ BRDA:229,30,1,0
3787
+ BRDA:232,31,0,0
3788
+ BRDA:232,31,1,0
3789
+ BRDA:236,32,0,0
3790
+ BRDA:236,32,1,0
3791
+ BRDA:246,33,0,0
3792
+ BRDA:246,33,1,0
3793
+ BRDA:260,34,0,0
3794
+ BRDA:260,34,1,0
3795
+ BRDA:267,35,0,0
3796
+ BRDA:267,35,1,0
3797
+ BRDA:284,36,0,0
3798
+ BRDA:284,36,1,0
3799
+ BRDA:284,37,0,0
3800
+ BRDA:284,37,1,0
3801
+ BRDA:307,38,0,0
3802
+ BRDA:307,38,1,0
3803
+ BRDA:307,39,0,0
3804
+ BRDA:307,39,1,0
3805
+ BRDA:307,39,2,0
3806
+ BRF:79
3800
3807
  BRH:0
3801
3808
  end_of_record
3802
3809
  TN:
@@ -16,7 +16,7 @@ const { cloneDeep } = require("lodash/fp");
16
16
  const csvParser = require("../../../utilities/csvParser");
17
17
  const { handleRequest } = require("../row/external");
18
18
  const { getAppDB } = require("@budibase/backend-core/context");
19
- function makeTableRequest(datasource, operation, table, tables, oldTable = null) {
19
+ function makeTableRequest(datasource, operation, table, tables, oldTable = null, renamed = null) {
20
20
  return __awaiter(this, void 0, void 0, function* () {
21
21
  const json = {
22
22
  endpoint: {
@@ -32,6 +32,9 @@ function makeTableRequest(datasource, operation, table, tables, oldTable = null)
32
32
  if (oldTable) {
33
33
  json.meta.table = oldTable;
34
34
  }
35
+ if (renamed) {
36
+ json.meta.renamed = renamed;
37
+ }
35
38
  return makeExternalQuery(datasource, json);
36
39
  });
37
40
  }
@@ -135,6 +138,7 @@ function isRelationshipSetup(column) {
135
138
  exports.save = function (ctx) {
136
139
  return __awaiter(this, void 0, void 0, function* () {
137
140
  const table = ctx.request.body;
141
+ const { _rename: renamed } = table;
138
142
  // can't do this right now
139
143
  delete table.dataImport;
140
144
  const datasourceId = getDatasourceId(ctx.request.body);
@@ -193,7 +197,7 @@ exports.save = function (ctx) {
193
197
  const operation = oldTable
194
198
  ? DataSourceOperation.UPDATE_TABLE
195
199
  : DataSourceOperation.CREATE_TABLE;
196
- yield makeTableRequest(datasource, operation, tableToSave, tables, oldTable);
200
+ yield makeTableRequest(datasource, operation, tableToSave, tables, oldTable, renamed);
197
201
  // update any extra tables (like foreign keys in other tables)
198
202
  for (let extraTable of extraTablesToUpdate) {
199
203
  const oldExtraTable = oldTables[extraTable.name];
@@ -206,6 +210,8 @@ exports.save = function (ctx) {
206
210
  if (Array.isArray(tableToSave.constrained)) {
207
211
  tableToSave.constrained = tableToSave.constrained.filter(constraint => Object.keys(tableToSave.schema).includes(constraint));
208
212
  }
213
+ // remove the rename prop
214
+ delete tableToSave._rename;
209
215
  // store it into couch now for budibase reference
210
216
  datasource.entities[tableToSave.name] = tableToSave;
211
217
  yield db.put(datasource);
@@ -232,6 +232,9 @@ class InternalBuilder {
232
232
  create(knex, json, opts) {
233
233
  const { endpoint, body } = json;
234
234
  let query = knex(endpoint.entityId);
235
+ if (endpoint.schema) {
236
+ query = query.withSchema(endpoint.schema);
237
+ }
235
238
  const parsedBody = parseBody(body);
236
239
  // make sure no null values in body for creation
237
240
  for (let [key, value] of Object.entries(parsedBody)) {
@@ -250,6 +253,9 @@ class InternalBuilder {
250
253
  bulkCreate(knex, json) {
251
254
  const { endpoint, body } = json;
252
255
  let query = knex(endpoint.entityId);
256
+ if (endpoint.schema) {
257
+ query = query.withSchema(endpoint.schema);
258
+ }
253
259
  if (!Array.isArray(body)) {
254
260
  return query;
255
261
  }
@@ -257,7 +263,7 @@ class InternalBuilder {
257
263
  return query.insert(parsedBody);
258
264
  }
259
265
  read(knex, json, limit) {
260
- let { endpoint, resource, filters, sort, paginate, relationships } = json;
266
+ let { endpoint, resource, filters, paginate, relationships } = json;
261
267
  const tableName = endpoint.entityId;
262
268
  // select all if not specified
263
269
  if (!resource) {
@@ -285,6 +291,9 @@ class InternalBuilder {
285
291
  }
286
292
  // start building the query
287
293
  let query = knex(tableName).limit(foundLimit);
294
+ if (endpoint.schema) {
295
+ query = query.withSchema(endpoint.schema);
296
+ }
288
297
  if (foundOffset) {
289
298
  query = query.offset(foundOffset);
290
299
  }
@@ -307,6 +316,9 @@ class InternalBuilder {
307
316
  update(knex, json, opts) {
308
317
  const { endpoint, body, filters } = json;
309
318
  let query = knex(endpoint.entityId);
319
+ if (endpoint.schema) {
320
+ query = query.withSchema(endpoint.schema);
321
+ }
310
322
  const parsedBody = parseBody(body);
311
323
  query = this.addFilters(query, filters, { tableName: endpoint.entityId });
312
324
  // mysql can't use returning
@@ -320,6 +332,9 @@ class InternalBuilder {
320
332
  delete(knex, json, opts) {
321
333
  const { endpoint, filters } = json;
322
334
  let query = knex(endpoint.entityId);
335
+ if (endpoint.schema) {
336
+ query = query.withSchema(endpoint.schema);
337
+ }
323
338
  query = this.addFilters(query, filters, { tableName: endpoint.entityId });
324
339
  // mysql can't use returning
325
340
  if (opts.disableReturning) {
@@ -4,7 +4,7 @@ const knex_1 = require("knex");
4
4
  const datasource_1 = require("../../definitions/datasource");
5
5
  const utils_1 = require("../utils");
6
6
  const { FieldTypes, RelationshipTypes } = require("../../constants");
7
- function generateSchema(schema, table, tables, oldTable = null) {
7
+ function generateSchema(schema, table, tables, oldTable = null, renamed) {
8
8
  let primaryKey = table && table.primary ? table.primary[0] : null;
9
9
  const columns = Object.values(table.schema);
10
10
  // all columns in a junction table will be meta
@@ -22,7 +22,9 @@ function generateSchema(schema, table, tables, oldTable = null) {
22
22
  for (let [key, column] of Object.entries(table.schema)) {
23
23
  // skip things that are already correct
24
24
  const oldColumn = oldTable ? oldTable.schema[key] : null;
25
- if ((oldColumn && oldColumn.type) || (primaryKey === key && !isJunction)) {
25
+ if ((oldColumn && oldColumn.type) ||
26
+ (primaryKey === key && !isJunction) ||
27
+ (renamed === null || renamed === void 0 ? void 0 : renamed.updated) === key) {
26
28
  continue;
27
29
  }
28
30
  switch (column.type) {
@@ -72,12 +74,18 @@ function generateSchema(schema, table, tables, oldTable = null) {
72
74
  break;
73
75
  }
74
76
  }
77
+ if (renamed) {
78
+ schema.renameColumn(renamed.old, renamed.updated);
79
+ }
75
80
  // need to check if any columns have been deleted
76
81
  if (oldTable) {
77
82
  const deletedColumns = Object.entries(oldTable.schema)
78
83
  .filter(([key, schema]) => schema.type !== FieldTypes.LINK && table.schema[key] == null)
79
84
  .map(([key]) => key);
80
85
  deletedColumns.forEach(key => {
86
+ if ((renamed === null || renamed === void 0 ? void 0 : renamed.old) === key) {
87
+ return;
88
+ }
81
89
  if (oldTable.constrained && oldTable.constrained.indexOf(key) !== -1) {
82
90
  schema.dropForeign(key);
83
91
  }
@@ -87,17 +95,17 @@ function generateSchema(schema, table, tables, oldTable = null) {
87
95
  return schema;
88
96
  }
89
97
  function buildCreateTable(knex, table, tables) {
90
- return knex.schema.createTable(table.name, schema => {
98
+ return knex.createTable(table.name, schema => {
91
99
  generateSchema(schema, table, tables);
92
100
  });
93
101
  }
94
- function buildUpdateTable(knex, table, tables, oldTable) {
95
- return knex.schema.alterTable(table.name, schema => {
96
- generateSchema(schema, table, tables, oldTable);
102
+ function buildUpdateTable(knex, table, tables, oldTable, renamed) {
103
+ return knex.alterTable(table.name, schema => {
104
+ generateSchema(schema, table, tables, oldTable, renamed);
97
105
  });
98
106
  }
99
107
  function buildDeleteTable(knex, table) {
100
- return knex.schema.dropTable(table.name);
108
+ return knex.dropTable(table.name);
101
109
  }
102
110
  class SqlTableQueryBuilder {
103
111
  // pass through client to get flavour of SQL
@@ -115,7 +123,11 @@ class SqlTableQueryBuilder {
115
123
  return json.endpoint.operation;
116
124
  }
117
125
  _tableQuery(json) {
118
- const client = knex_1.knex({ client: this.sqlClient });
126
+ var _a;
127
+ let client = knex_1.knex({ client: this.sqlClient }).schema;
128
+ if ((_a = json === null || json === void 0 ? void 0 : json.endpoint) === null || _a === void 0 ? void 0 : _a.schema) {
129
+ client = client.withSchema(json.endpoint.schema);
130
+ }
119
131
  let query;
120
132
  if (!json.table || !json.meta || !json.meta.tables) {
121
133
  throw "Cannot execute without table being specified";
@@ -128,7 +140,7 @@ class SqlTableQueryBuilder {
128
140
  if (!json.meta || !json.meta.table) {
129
141
  throw "Must specify old table for update";
130
142
  }
131
- query = buildUpdateTable(client, json.table, json.meta.tables, json.meta.table);
143
+ query = buildUpdateTable(client, json.table, json.meta.tables, json.meta.table, json.meta.renamed);
132
144
  break;
133
145
  case datasource_1.Operation.DELETE_TABLE:
134
146
  query = buildDeleteTable(client, json.table);
@@ -15,6 +15,7 @@ var MSSQLModule;
15
15
  (function (MSSQLModule) {
16
16
  const sqlServer = require("mssql");
17
17
  const Sql = require("./base/sql");
18
+ const DEFAULT_SCHEMA = "dbo";
18
19
  const SCHEMA = {
19
20
  docs: "https://github.com/tediousjs/node-mssql",
20
21
  plus: true,
@@ -43,6 +44,10 @@ var MSSQLModule;
43
44
  type: datasource_1.DatasourceFieldTypes.STRING,
44
45
  default: "root",
45
46
  },
47
+ schema: {
48
+ type: datasource_1.DatasourceFieldTypes.STRING,
49
+ default: DEFAULT_SCHEMA,
50
+ },
46
51
  encrypt: {
47
52
  type: datasource_1.DatasourceFieldTypes.BOOLEAN,
48
53
  default: true,
@@ -87,6 +92,20 @@ var MSSQLModule;
87
92
  this.pool = new sqlServer.ConnectionPool(clientCfg);
88
93
  }
89
94
  }
95
+ getBindingIdentifier() {
96
+ return `(@p${this.index++})`;
97
+ }
98
+ connect() {
99
+ return __awaiter(this, void 0, void 0, function* () {
100
+ try {
101
+ this.client = yield this.pool.connect();
102
+ }
103
+ catch (err) {
104
+ // @ts-ignore
105
+ throw new Error(err);
106
+ }
107
+ });
108
+ }
90
109
  internalQuery(query, operation = undefined) {
91
110
  return __awaiter(this, void 0, void 0, function* () {
92
111
  const client = this.client;
@@ -137,20 +156,6 @@ var MSSQLModule;
137
156
  FROM INFORMATION_SCHEMA.COLUMNS
138
157
  WHERE TABLE_NAME='${tableName}'`;
139
158
  }
140
- getBindingIdentifier() {
141
- return `(@p${this.index++})`;
142
- }
143
- connect() {
144
- return __awaiter(this, void 0, void 0, function* () {
145
- try {
146
- this.client = yield this.pool.connect();
147
- }
148
- catch (err) {
149
- // @ts-ignore
150
- throw new Error(err);
151
- }
152
- });
153
- }
154
159
  runSQL(sql) {
155
160
  return __awaiter(this, void 0, void 0, function* () {
156
161
  return (yield this.internalQuery(utils_1.getSqlQuery(sql))).recordset;
@@ -164,11 +169,13 @@ var MSSQLModule;
164
169
  buildSchema(datasourceId, entities) {
165
170
  return __awaiter(this, void 0, void 0, function* () {
166
171
  yield this.connect();
167
- let tableNames = yield this.runSQL(this.TABLES_SQL);
168
- if (tableNames == null || !Array.isArray(tableNames)) {
172
+ let tableInfo = yield this.runSQL(this.TABLES_SQL);
173
+ if (tableInfo == null || !Array.isArray(tableInfo)) {
169
174
  throw "Unable to get list of tables in database";
170
175
  }
171
- tableNames = tableNames
176
+ const schema = this.config.schema || DEFAULT_SCHEMA;
177
+ const tableNames = tableInfo
178
+ .filter((record) => record.TABLE_SCHEMA === schema)
172
179
  .map((record) => record.TABLE_NAME)
173
180
  .filter((name) => this.MASTER_TABLES.indexOf(name) === -1);
174
181
  const tables = {};
@@ -240,7 +247,11 @@ var MSSQLModule;
240
247
  }
241
248
  query(json) {
242
249
  return __awaiter(this, void 0, void 0, function* () {
250
+ const schema = this.config.schema;
243
251
  yield this.connect();
252
+ if (schema && schema !== DEFAULT_SCHEMA && (json === null || json === void 0 ? void 0 : json.endpoint)) {
253
+ json.endpoint.schema = schema;
254
+ }
244
255
  const operation = this._operation(json);
245
256
  const queryFn = (query, op) => this.internalQuery(query, op);
246
257
  const processFn = (result) => result.recordset ? result.recordset : [{ [operation]: true }];