diff --git a/.github/workflows/budibase_ci.yml b/.github/workflows/budibase_ci.yml index 2151e1e342..e2f000cf7e 100644 --- a/.github/workflows/budibase_ci.yml +++ b/.github/workflows/budibase_ci.yml @@ -155,7 +155,7 @@ jobs: strategy: matrix: datasource: - [mssql, mysql, postgres, mongodb, mariadb, oracle, sqs, none] + [mssql, mysql, postgres, postgres_legacy, mongodb, mariadb, oracle, sqs, none] steps: - name: Checkout repo uses: actions/checkout@v4 @@ -190,6 +190,8 @@ jobs: docker pull mariadb@${{ steps.dotenv.outputs.MARIADB_SHA }} elif [ "${{ matrix.datasource }}" == "oracle" ]; then docker pull budibase/oracle-database:23.2-slim-faststart + elif [ "${{ matrix.datasource }}" == "postgres_legacy" ]; then + docker pull postgres:9.5.25 fi docker pull minio/minio & docker pull redis & diff --git a/examples/nextjs-api-sales/yarn.lock b/examples/nextjs-api-sales/yarn.lock index d4ba8a29a5..40bf33da70 100644 --- a/examples/nextjs-api-sales/yarn.lock +++ b/examples/nextjs-api-sales/yarn.lock @@ -1244,9 +1244,9 @@ ms@^2.1.1: integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== nanoid@^3.3.6: - version "3.3.7" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.7.tgz#d0c301a691bc8d54efa0a2226ccf3fe2fd656bd8" - integrity sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g== + version "3.3.8" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.8.tgz#b1be3030bee36aaff18bacb375e5cce521684baf" + integrity sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w== natural-compare@^1.4.0: version "1.4.0" diff --git a/lerna.json b/lerna.json index d893fc97bd..055b5c3ce7 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "version": "3.2.27", + "version": "3.2.28", "npmClient": "yarn", "concurrency": 20, "command": { diff --git a/packages/client/package.json b/packages/client/package.json index 7c266bba1d..2ae049f6d0 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -16,7 +16,7 @@ }, "scripts": { "build": "vite build", - "dev": "vite build --watch" + "dev": "vite build --watch --mode=dev" }, "dependencies": { "@budibase/bbui": "*", diff --git a/packages/client/vite.config.mjs b/packages/client/vite.config.mjs index 9c623b709f..22f451fadd 100644 --- a/packages/client/vite.config.mjs +++ b/packages/client/vite.config.mjs @@ -25,8 +25,8 @@ export default defineConfig(({ mode }) => { outDir: "dist", name: "budibase_client", fileName: () => "budibase-client.js", - minify: isProduction, }, + minify: isProduction, }, plugins: [ svelte({ diff --git a/packages/pro b/packages/pro index 977baca179..e7c9f08aeb 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit 977baca179fef1192f8fe051122288a4128f7a63 +Subproject commit e7c9f08aeb0498a20594f3c912afedcfdc220a6a diff --git a/packages/server/src/api/routes/tests/datasource.spec.ts b/packages/server/src/api/routes/tests/datasource.spec.ts index 514ed02c86..21e9effa77 100644 --- a/packages/server/src/api/routes/tests/datasource.spec.ts +++ b/packages/server/src/api/routes/tests/datasource.spec.ts @@ -596,7 +596,7 @@ const datasources = datasourceDescribe({ if (datasources.length) { describe.each(datasources)( "$dbName", - ({ config, dsProvider, isPostgres, isMySQL, isMariaDB }) => { + ({ config, dsProvider, isPostgres, isLegacy, isMySQL, isMariaDB }) => { let datasource: Datasource let client: Knex @@ -647,6 +647,13 @@ if (datasources.length) { // can load it. We're using postgres 16 in tests at the time of writing. schema = schema.replace("SET transaction_timeout = 0;", "") } + if (isPostgres && isLegacy) { + // in older versions of Postgres, this is not a valid option - Postgres 9.5 does not support this. + schema = schema.replace( + "SET idle_in_transaction_session_timeout = 0;", + "" + ) + } await config.api.table.destroy(table._id!, table._rev!) diff --git a/packages/server/src/integration-test/postgres.spec.ts b/packages/server/src/integration-test/postgres.spec.ts index 88250373f8..6e674aa58e 100644 --- a/packages/server/src/integration-test/postgres.spec.ts +++ b/packages/server/src/integration-test/postgres.spec.ts @@ -1,5 +1,4 @@ import { Datasource, FieldType, Table } from "@budibase/types" -import _ from "lodash" import { generator } from "@budibase/backend-core/tests" import { DatabaseName, @@ -8,7 +7,9 @@ import { } from "../integrations/tests/utils" import { Knex } from "knex" -const mainDescriptions = datasourceDescribe({ only: [DatabaseName.POSTGRES] }) +const mainDescriptions = datasourceDescribe({ + only: [DatabaseName.POSTGRES, DatabaseName.POSTGRES_LEGACY], +}) if (mainDescriptions.length) { describe.each(mainDescriptions)( diff --git a/packages/server/src/integrations/postgres.ts b/packages/server/src/integrations/postgres.ts index 5551d33778..33c2d76a96 100644 --- a/packages/server/src/integrations/postgres.ts +++ b/packages/server/src/integrations/postgres.ts @@ -173,8 +173,13 @@ class PostgresIntegration extends Sql implements DatasourcePlus { ` COLUMNS_SQL = () => ` - select * from information_schema.columns where table_schema = ANY(current_schemas(false)) - AND pg_table_is_visible(to_regclass(format('%I.%I', table_schema, table_name))); + SELECT columns.* + FROM information_schema.columns columns + JOIN pg_class pg_class ON pg_class.relname = columns.table_name + JOIN pg_namespace name_space ON name_space.oid = pg_class.relnamespace + WHERE columns.table_schema = ANY(current_schemas(false)) + AND columns.table_schema = name_space.nspname + AND pg_table_is_visible(pg_class.oid); ` constructor(config: PostgresConfig) { diff --git a/packages/server/src/integrations/tests/utils/images.ts b/packages/server/src/integrations/tests/utils/images.ts index 8c2bb9b220..00686412c6 100644 --- a/packages/server/src/integrations/tests/utils/images.ts +++ b/packages/server/src/integrations/tests/utils/images.ts @@ -9,5 +9,6 @@ dotenv.config({ export const MSSQL_IMAGE = `mcr.microsoft.com/mssql/server@${process.env.MSSQL_SHA}` export const MYSQL_IMAGE = `mysql@${process.env.MYSQL_SHA}` export const POSTGRES_IMAGE = `postgres@${process.env.POSTGRES_SHA}` +export const POSTGRES_LEGACY_IMAGE = `postgres:9.5.25` export const MONGODB_IMAGE = `mongo@${process.env.MONGODB_SHA}` export const MARIADB_IMAGE = `mariadb@${process.env.MARIADB_SHA}` diff --git a/packages/server/src/integrations/tests/utils/index.ts b/packages/server/src/integrations/tests/utils/index.ts index cdf2c4021c..9e2c4f7e70 100644 --- a/packages/server/src/integrations/tests/utils/index.ts +++ b/packages/server/src/integrations/tests/utils/index.ts @@ -16,6 +16,7 @@ export const { startContainer } = testContainerUtils export enum DatabaseName { POSTGRES = "postgres", + POSTGRES_LEGACY = "postgres_legacy", MONGODB = "mongodb", MYSQL = "mysql", SQL_SERVER = "mssql", @@ -26,6 +27,7 @@ export enum DatabaseName { const providers: Record = { [DatabaseName.POSTGRES]: postgres.getDatasource, + [DatabaseName.POSTGRES_LEGACY]: postgres.getLegacyDatasource, [DatabaseName.MONGODB]: mongodb.getDatasource, [DatabaseName.MYSQL]: mysql.getDatasource, [DatabaseName.SQL_SERVER]: mssql.getDatasource, @@ -145,7 +147,11 @@ export function datasourceDescribe(opts: DatasourceDescribeOpts) { DatabaseName.ORACLE, ].includes(dbName), isMySQL: dbName === DatabaseName.MYSQL, - isPostgres: dbName === DatabaseName.POSTGRES, + isPostgres: + dbName === DatabaseName.POSTGRES || + dbName === DatabaseName.POSTGRES_LEGACY, + // check if any of the legacy tags + isLegacy: dbName === DatabaseName.POSTGRES_LEGACY, isMongodb: dbName === DatabaseName.MONGODB, isMSSQL: dbName === DatabaseName.SQL_SERVER, isOracle: dbName === DatabaseName.ORACLE, diff --git a/packages/server/src/integrations/tests/utils/postgres.ts b/packages/server/src/integrations/tests/utils/postgres.ts index fc52a724ad..cca127e84f 100644 --- a/packages/server/src/integrations/tests/utils/postgres.ts +++ b/packages/server/src/integrations/tests/utils/postgres.ts @@ -3,14 +3,14 @@ import { GenericContainer, Wait } from "testcontainers" import { generator, testContainerUtils } from "@budibase/backend-core/tests" import { startContainer } from "." import knex, { Knex } from "knex" -import { POSTGRES_IMAGE } from "./images" +import { POSTGRES_IMAGE, POSTGRES_LEGACY_IMAGE } from "./images" let ports: Promise -export async function getDatasource(): Promise { +async function datasourceWithImage(image: string): Promise { if (!ports) { ports = startContainer( - new GenericContainer(POSTGRES_IMAGE) + new GenericContainer(image) .withExposedPorts(5432) .withEnvironment({ POSTGRES_PASSWORD: "password" }) .withWaitStrategy( @@ -51,6 +51,14 @@ export async function getDatasource(): Promise { return datasource } +export async function getDatasource(): Promise { + return datasourceWithImage(POSTGRES_IMAGE) +} + +export async function getLegacyDatasource(): Promise { + return datasourceWithImage(POSTGRES_LEGACY_IMAGE) +} + export async function knexClient( ds: Datasource, opts?: Knex.Config diff --git a/packages/string-templates/rollup.config.js b/packages/string-templates/rollup.config.js index d06efc3539..cfe78aee57 100644 --- a/packages/string-templates/rollup.config.js +++ b/packages/string-templates/rollup.config.js @@ -32,7 +32,7 @@ const config = (input, outputFile, format) => ({ }), commonjs(), json(), - inject({ Buffer: ["buffer", "Buffer"] }), + inject({ Buffer: ["buffer", "Buffer"], process: "process/browser" }), production && terser(), ], }) diff --git a/yarn.lock b/yarn.lock index 442d6e65e1..aa409fe4a1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16187,9 +16187,9 @@ path-scurry@^1.11.1, path-scurry@^1.6.1: minipass "^5.0.0 || ^6.0.2 || ^7.0.0" path-to-regexp@^0.1.10: - version "0.1.11" - resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.11.tgz#a527e662c89efc4646dbfa8100bf3e847e495761" - integrity sha512-c0t+KCuUkO/YDLPG4WWzEwx3J5F/GHXsD1h/SNZfySqAIKe/BaP95x8fWtOfRJokpS5yYHRJjMtYlXD8jxnpbw== + version "0.1.12" + resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.12.tgz#d5e1a12e478a976d432ef3c58d534b9923164bb7" + integrity sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ== path-to-regexp@^6.1.0, path-to-regexp@^6.3.0: version "6.3.0"