Skip to content

Commit

Permalink
fix: duplicate prefix fails on Stardog
Browse files Browse the repository at this point in the history
  • Loading branch information
tpluscode committed Feb 13, 2025
1 parent efb0c45 commit 3405d1b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions apis/shared-dimensions/lib/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { rdf, schema, sh } from '@tpluscode/rdf-ns-builders/strict'
import onetime from 'onetime'
import { isGraphPointer } from 'is-graph-pointer'
import $rdf from 'rdf-ext'
import { sparql } from '@tpluscode/rdf-string'
import { sparql, SparqlTemplateResult } from '@tpluscode/rdf-string'
import { SharedDimensionsStore } from '../store'
import shapeToQuery from '../shapeToQuery'
import { loadShapes } from './shapes'
Expand Down Expand Up @@ -43,16 +43,19 @@ export default class implements SharedDimensionsStore {
}

async save(resource: GraphPointer<NamedNode>): Promise<void> {
let updateQuery = INSERT.DATA`
let updateQuery: SparqlTemplateResult
const insertQuery = INSERT.DATA`
GRAPH ${this.graph} {
${resource.dataset}
}
`._getTemplateResult()
`

if (await this.exists(resource.term)) {
const shape = await this.getShape(resource.term)
const deleteQuery = await this.deleteQuery(shape, resource.term)
updateQuery = sparql`${deleteQuery};\n${updateQuery}`
updateQuery = sparql`${deleteQuery};\n${insertQuery}`
} else {
updateQuery = insertQuery._getTemplateResult()
}

await this.client.query.update(updateQuery.toString())
Expand Down

0 comments on commit 3405d1b

Please sign in to comment.