Giter Site home page Giter Site logo

Comments (9)

danitseitlin avatar danitseitlin commented on May 19, 2024

@FallingSnow Hi, I am looking on https://oss.redislabs.com/redisgraph/commands/#graphquery and It doesn't seem aligned with what you shared. I will try to check what should be the correct syntax and update the code accordingly.
Thanks for your issue.

from redis-modules-sdk-ts.

danitseitlin avatar danitseitlin commented on May 19, 2024

@FallingSnow Can you share your exact usage?

from redis-modules-sdk-ts.

FallingSnow avatar FallingSnow commented on May 19, 2024

I'm trying to escape user input in queries I submit to the database. Some libraries provide this escape function. Considering redis returns Missing parameters I think it might be native to redis.

Query:

MATCH (p:user) WHERE p.email=$email RETURN count(p) as count

Response:

Error: RedisGraph class (GRAPH.QUERY): ReplyError: Missing parameters

from redis-modules-sdk-ts.

danitseitlin avatar danitseitlin commented on May 19, 2024

@FallingSnow Can you share your usage with the redis-modules-sdk?

from redis-modules-sdk-ts.

FallingSnow avatar FallingSnow commented on May 19, 2024

That is.

export default class Database extends RedisGraph {
  constructor(...args) {
    super({ port: options.databasePort, host: options.databaseHost, ...args });
  }

  async query(query: string) {
    try {
     // Throws "Error: RedisGraph class (GRAPH.QUERY): ReplyError: Missing parameters"
      return await super.query(options.databaseName, query);
    } catch (error) {
      log.error("Failed to run database query: \"%s\"\n%s", query, error);
      throw new Error("Database error. See server logs.");
    }
  }

  static escape(str) {
    return str.replace(/'/g, "\\'");
  }
}

// Doesn't work
const matches = await database.query(`MATCH (p:user) WHERE p.email=$email RETURN count(p) as count`);

// Works
const matches = await database.query(`MATCH (p:user) WHERE p.email='[email protected]' RETURN count(p) as count`);

from redis-modules-sdk-ts.

FallingSnow avatar FallingSnow commented on May 19, 2024

Are you unable to replicate the error with a query that has a $ (dollar sign) variable?

from redis-modules-sdk-ts.

danitseitlin avatar danitseitlin commented on May 19, 2024

@FallingSnow hi, yes i am able. Sorry for the delay i will be working on this and many issues this weekend and next week.

from redis-modules-sdk-ts.

danitseitlin avatar danitseitlin commented on May 19, 2024

@FallingSnow Hi, should have a fix soon, just running some last tests.

from redis-modules-sdk-ts.

FallingSnow avatar FallingSnow commented on May 19, 2024

Great! Thank you!

from redis-modules-sdk-ts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.