Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Queries with DEFINE statement are not executed #41

Open
LuanLuna opened this issue Jul 17, 2024 · 3 comments
Open

Queries with DEFINE statement are not executed #41

LuanLuna opened this issue Jul 17, 2024 · 3 comments

Comments

@LuanLuna
Copy link

LuanLuna commented Jul 17, 2024

When i try to execute some query like DEFINE INDEX.. or DEFINE ANALYZER.. the execution never ends and the application stays
locked waiting for the end. But other queries like SELECT, UPDATE, DELETE... work fine.
Obs: The DEFINE execution never ends, and the change do not reflet on data base.

Connection:

private async _connectAndSignIn() {
    const username = this.config.get<string>('SURREAL_DB_USER');
    const password = this.config.get<string>('SURREAL_DB_PASSWORD');
    const namespace = this.config.get<string>('SURREAL_DB_NS');
    const database = this.config.get<string>('SURREAL_DB_DATABASE');
    const dbUrl = this.config.get<string>('SURREAL_DB_PORT');

    this.logger.log(
      "Connecting to local Surrealdb ${inspect({
        namespace,
        database,
        url: dbUrl,
      })}",
    );
    try {
      await this.db.connect(dbUrl);

      this.logger.log("Surrealdb connection works");

      await this.db.use({ ns: namespace, db: database });

      await this.db.signin({
        username: username,
        password: password,
      });

      this.logger.log("Surrealdb signIn works");
    } catch (error) {
      this.logger.error(
        '_connectAndSignIn error: ',
        inspect({ error }, { depth: null }),
      );
    }
  }

Query method:

async query<T = any>(query: string): Promise<T[]> {
    try {
      const result = (await this.db.query(query)) as T[];

      return result;
    } catch (error) {
      const err = `query error: ${inspect({ error })}`;
      this.logger.error(err);
      throw new InternalServerErrorException(error);
    }
  }

Query:
DEFINE ANALYZER simplePt TOKENIZERS blank, class, punct FILTERS snowball(Portuguese), edgengram(1,3);
App log:
image

@CanRau
Copy link

CanRau commented Jul 17, 2024

What version are you running?

@LuanLuna
Copy link
Author

LuanLuna commented Jul 17, 2024

@CanRau
SurrealDB version: 1.5.2
surrealdb.node: 0.3.0

@CanRau
Copy link

CanRau commented Jul 17, 2024

I'd recommend trying 1.0.0-beta.1 tho you have to check the readme as usage has changed a little

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants