From aa5799df68ea982d195469f39a1baf6c31d575b3 Mon Sep 17 00:00:00 2001 From: Alexey Zorkaltsev Date: Mon, 5 Aug 2024 17:06:41 +0300 Subject: [PATCH] chore: fix query service example --- .../index.ts | 17 +++++++++++++---- .../graceful-session-close.test.ts | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/examples/basic-example-v2-with-query-service/index.ts b/examples/basic-example-v2-with-query-service/index.ts index 70ab6fed..2d6c5779 100644 --- a/examples/basic-example-v2-with-query-service/index.ts +++ b/examples/basic-example-v2-with-query-service/index.ts @@ -1,6 +1,7 @@ import {Driver, getCredentialsFromEnv, Logger, RowType} from 'ydb-sdk'; import {Episode, getEpisodesData, getSeasonsData, getSeriesData, Series} from './data-helpers'; import {main} from '../utils'; +import {SchemeError} from "../../src/errors"; process.env.YDB_SDK_PRETTY_LOGS = '1'; @@ -12,12 +13,20 @@ async function createTables(driver: Driver, logger: Logger) { logger.info('Dropping old tables and create new ones...'); await driver.queryClient.do({ fn: async (session) => { + + try { + await session.execute({ + text: ` + DROP TABLE ${SERIES_TABLE}; + DROP TABLE ${EPISODES_TABLE}; + DROP TABLE ${SEASONS_TABLE};`, + }); + } catch (err) { // Ignore if tables are missing + if (err instanceof SchemeError) throw err; + } + await session.execute({ text: ` - DROP TABLE IF EXISTS ${SERIES_TABLE}; - DROP TABLE IF EXISTS ${EPISODES_TABLE}; - DROP TABLE IF EXISTS ${SEASONS_TABLE}; - CREATE TABLE ${SERIES_TABLE} ( series_id UInt64, diff --git a/src/__tests__/e2e/table-service/graceful-session-close.test.ts b/src/__tests__/e2e/table-service/graceful-session-close.test.ts index d5c3518e..b26fb480 100644 --- a/src/__tests__/e2e/table-service/graceful-session-close.test.ts +++ b/src/__tests__/e2e/table-service/graceful-session-close.test.ts @@ -6,7 +6,7 @@ import {initDriver, destroyDriver} from "../../../utils/test"; const SHUTDOWN_URL = process.env.YDB_SHUTDOWN_URL || 'http://localhost:8765/actors/kqp_proxy?force_shutdown=all'; -xdescribe('Graceful session close', () => { +describe('Graceful session close', () => { // TODO: Fix and enable test nce issue will be resolved https://github.com/ydb-platform/ydb/issues/2981 // TODO: Make the same test for query service