1
0
Fork 0
mirror of synced 2024-09-20 19:33:10 +12:00

Merge branch 'master' into dean-fixes

This commit is contained in:
deanhannigan 2024-08-07 09:58:09 +01:00 committed by GitHub
commit c7c1c257dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 67 additions and 30 deletions

View file

@ -147,7 +147,7 @@ jobs:
fi fi
test-server: test-server:
runs-on: budi-tubby-tornado-quad-core-150gb runs-on: budi-tubby-tornado-quad-core-300gb
steps: steps:
- name: Checkout repo - name: Checkout repo
uses: actions/checkout@v4 uses: actions/checkout@v4

View file

@ -116,7 +116,7 @@ As with anything that we build in Budibase, our new public API is simple to use,
You can learn more about the Budibase API at the following places: You can learn more about the Budibase API at the following places:
- [General documentation](https://docs.budibase.com/docs/public-api): Learn how to get your API key, how to use spec, and how to use Postman - [General documentation](https://docs.budibase.com/docs/public-api): Learn how to get your API key, how to use spec, and how to use Postman
- [Interactive API documentation](https://docs.budibase.com/reference/post_applications) : Learn how to interact with the API - [Interactive API documentation](https://docs.budibase.com/reference/appcreate) : Learn how to interact with the API
<br /><br /> <br /><br />

View file

@ -144,7 +144,7 @@ del sistema. Budibase API ofrece:
Puedes aprender mas acerca de Budibase API en los siguientes documentos: Puedes aprender mas acerca de Budibase API en los siguientes documentos:
- [Documentacion general](https://docs.budibase.com/docs/public-api) : Como optener tu clave para la API, usar Insomnia y Postman - [Documentacion general](https://docs.budibase.com/docs/public-api) : Como optener tu clave para la API, usar Insomnia y Postman
- [API Interactiva](https://docs.budibase.com/reference/post_applications) : Aprende como trabajar con la API - [API Interactiva](https://docs.budibase.com/reference/appcreate) : Aprende como trabajar con la API
#### Guias #### Guias

View file

@ -80,7 +80,7 @@
"dotenv": "8.2.0", "dotenv": "8.2.0",
"form-data": "4.0.0", "form-data": "4.0.0",
"global-agent": "3.0.0", "global-agent": "3.0.0",
"google-spreadsheet": "npm:@budibase/google-spreadsheet@4.1.2", "google-spreadsheet": "npm:@budibase/google-spreadsheet@4.1.3",
"ioredis": "5.3.2", "ioredis": "5.3.2",
"isolated-vm": "^4.7.2", "isolated-vm": "^4.7.2",
"jimp": "0.22.12", "jimp": "0.22.12",

View file

@ -17,9 +17,14 @@ import {
SupportedSqlTypes, SupportedSqlTypes,
JsonFieldSubType, JsonFieldSubType,
} from "@budibase/types" } from "@budibase/types"
import { DatabaseName, getDatasource } from "../../../integrations/tests/utils" import {
DatabaseName,
getDatasource,
knexClient,
} from "../../../integrations/tests/utils"
import { tableForDatasource } from "../../../tests/utilities/structures" import { tableForDatasource } from "../../../tests/utilities/structures"
import nock from "nock" import nock from "nock"
import { Knex } from "knex"
describe("/datasources", () => { describe("/datasources", () => {
const config = setup.getConfig() const config = setup.getConfig()
@ -164,11 +169,15 @@ describe("/datasources", () => {
[DatabaseName.MYSQL, getDatasource(DatabaseName.MYSQL)], [DatabaseName.MYSQL, getDatasource(DatabaseName.MYSQL)],
[DatabaseName.SQL_SERVER, getDatasource(DatabaseName.SQL_SERVER)], [DatabaseName.SQL_SERVER, getDatasource(DatabaseName.SQL_SERVER)],
[DatabaseName.MARIADB, getDatasource(DatabaseName.MARIADB)], [DatabaseName.MARIADB, getDatasource(DatabaseName.MARIADB)],
[DatabaseName.ORACLE, getDatasource(DatabaseName.ORACLE)],
])("%s", (_, dsProvider) => { ])("%s", (_, dsProvider) => {
let rawDatasource: Datasource let rawDatasource: Datasource
let client: Knex
beforeEach(async () => { beforeEach(async () => {
rawDatasource = await dsProvider rawDatasource = await dsProvider
datasource = await config.api.datasource.create(rawDatasource) datasource = await config.api.datasource.create(rawDatasource)
client = await knexClient(rawDatasource)
}) })
describe("get", () => { describe("get", () => {
@ -285,9 +294,6 @@ describe("/datasources", () => {
[FieldType.STRING]: { [FieldType.STRING]: {
name: stringName, name: stringName,
type: FieldType.STRING, type: FieldType.STRING,
constraints: {
presence: true,
},
}, },
[FieldType.LONGFORM]: { [FieldType.LONGFORM]: {
name: "longform", name: "longform",
@ -381,10 +387,6 @@ describe("/datasources", () => {
), ),
schema: Object.entries(table.schema).reduce<TableSchema>( schema: Object.entries(table.schema).reduce<TableSchema>(
(acc, [fieldName, field]) => { (acc, [fieldName, field]) => {
// the constraint will be unset - as the DB doesn't recognise it as not null
if (fieldName === stringName) {
field.constraints = {}
}
acc[fieldName] = expect.objectContaining({ acc[fieldName] = expect.objectContaining({
...field, ...field,
}) })
@ -441,20 +443,49 @@ describe("/datasources", () => {
}) })
describe("info", () => { describe("info", () => {
it("should fetch information about postgres datasource", async () => { it("should fetch information about a datasource with a single table", async () => {
const table = await config.api.table.save( const existingTableNames = (
tableForDatasource(datasource, { await config.api.datasource.info(datasource)
schema: { ).tableNames
name: {
name: "name", const tableName = generator.guid()
type: FieldType.STRING, await client.schema.createTable(tableName, table => {
}, table.increments("id").primary()
}, table.string("name")
}) })
)
const info = await config.api.datasource.info(datasource) const info = await config.api.datasource.info(datasource)
expect(info.tableNames).toContain(table.name) expect(info.tableNames).toEqual(
expect.arrayContaining([tableName, ...existingTableNames])
)
expect(info.tableNames).toHaveLength(existingTableNames.length + 1)
})
it("should fetch information about a datasource with multiple tables", async () => {
const existingTableNames = (
await config.api.datasource.info(datasource)
).tableNames
const tableNames = [
generator.guid(),
generator.guid(),
generator.guid(),
generator.guid(),
]
for (const tableName of tableNames) {
await client.schema.createTable(tableName, table => {
table.increments("id").primary()
table.string("name")
})
}
const info = await config.api.datasource.info(datasource)
expect(info.tableNames).toEqual(
expect.arrayContaining([...tableNames, ...existingTableNames])
)
expect(info.tableNames).toHaveLength(
existingTableNames.length + tableNames.length
)
}) })
}) })
}) })

View file

@ -400,7 +400,9 @@ class OracleIntegration extends Sql implements DatasourcePlus {
if (oracleConstraint.type === OracleContraintTypes.PRIMARY) { if (oracleConstraint.type === OracleContraintTypes.PRIMARY) {
table.primary!.push(columnName) table.primary!.push(columnName)
} else if ( } else if (
oracleConstraint.type === OracleContraintTypes.NOT_NULL_OR_CHECK oracleConstraint.type ===
OracleContraintTypes.NOT_NULL_OR_CHECK &&
oracleConstraint.searchCondition?.endsWith("IS NOT NULL")
) { ) {
table.schema[columnName].constraints = { table.schema[columnName].constraints = {
presence: true, presence: true,
@ -421,7 +423,11 @@ class OracleIntegration extends Sql implements DatasourcePlus {
const columnsResponse = await this.internalQuery<OracleColumnsResponse>({ const columnsResponse = await this.internalQuery<OracleColumnsResponse>({
sql: OracleIntegration.COLUMNS_SQL, sql: OracleIntegration.COLUMNS_SQL,
}) })
return (columnsResponse.rows || []).map(row => row.TABLE_NAME) const tableNames = new Set<string>()
for (const row of columnsResponse.rows || []) {
tableNames.add(row.TABLE_NAME)
}
return Array.from(tableNames)
} }
async testConnection() { async testConnection() {

View file

@ -12072,10 +12072,10 @@ google-p12-pem@^4.0.0:
dependencies: dependencies:
node-forge "^1.3.1" node-forge "^1.3.1"
"google-spreadsheet@npm:@budibase/google-spreadsheet@4.1.2": "google-spreadsheet@npm:@budibase/google-spreadsheet@4.1.3":
version "4.1.2" version "4.1.3"
resolved "https://registry.yarnpkg.com/@budibase/google-spreadsheet/-/google-spreadsheet-4.1.2.tgz#90548ccba2284b3042b08d2974ef3caeaf772ad9" resolved "https://registry.yarnpkg.com/@budibase/google-spreadsheet/-/google-spreadsheet-4.1.3.tgz#bcee7bd9d90f82c54b16a9aca963b87aceb050ad"
integrity sha512-dxoY3rQGGnuNeZiXhNc9oYPduzU8xnIjWujFwNvaRRv3zWeUV7mj6HE2o/OJOeekPGt7o44B+w6DfkiaoteZgg== integrity sha512-03VX3/K5NXIh6+XAIDZgcHPmR76xwd8vIDL7RedMpvM2IcXK0Iq/KU7FmLY0t/mKqORAGC7+0rajd0jLFezC4w==
dependencies: dependencies:
axios "^1.4.0" axios "^1.4.0"
lodash "^4.17.21" lodash "^4.17.21"