fix: handle uri in object (#1091)

Fixes #1078
This commit is contained in:
Will Jones
2024-03-12 13:25:56 -07:00
committed by Weston Pace
parent 47daf9b7b0
commit f0c5f5ba62
2 changed files with 17 additions and 11 deletions

View File

@@ -176,16 +176,21 @@ export async function connect (
opts = { uri: arg }
} else {
// opts = { uri: arg.uri, awsCredentials = arg.awsCredentials }
opts = Object.assign(
{
uri: '',
awsCredentials: undefined,
awsRegion: defaultAwsRegion,
apiKey: undefined,
region: defaultAwsRegion
},
arg
)
const keys = Object.keys(arg)
if (keys.length === 1 && keys[0] === 'uri' && typeof arg.uri === 'string') {
opts = { uri: arg.uri }
} else {
opts = Object.assign(
{
uri: '',
awsCredentials: undefined,
awsRegion: defaultAwsRegion,
apiKey: undefined,
region: defaultAwsRegion
},
arg
)
}
}
if (opts.uri.startsWith('db://')) {

View File

@@ -288,7 +288,8 @@ describe('LanceDB client', function () {
it('create a table from an Arrow Table', async function () {
const dir = await track().mkdir('lancejs')
const con = await lancedb.connect(dir)
// Also test the connect function with an object
const con = await lancedb.connect({ uri: dir })
const i32s = new Int32Array(new Array<number>(10))
const i32 = makeVector(i32s)