Coder Social home page Coder Social logo

hack-sql-fake's People

Contributors

akiljames83 avatar alexandresen avatar anirbanmu avatar arka-g avatar ashleymcm avatar atielking avatar chaseajen avatar fredemmott avatar henryr avatar jzimmerman95 avatar k128kevin avatar lexidor avatar madmx5 avatar mmckeen avatar muglug avatar mwshortt avatar pbibra avatar pmattj avatar sameerathangudu avatar ssandler avatar tanjinx avatar yazmortaz avatar zmagg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hack-sql-fake's Issues

Enforce data type sizes

Currently we enforce in DataIntegrity that ints are ints and strings are strings, but we don't check lengths (like varchar(N) and int vs. bigint). We do parse this information so this shouldn't be too hard.

Support AsyncMysqlQueryErrorResult and SQLFakeAsyncMysqlException

Issue template for hack-sql-fake

Please select the options that apply

  • Feature request
  • Question
  • Suggestion
  • Typechecker errors
  • Incorrect result
  • Cripplingly bad performance
  • Crash

Follow the template for your checked checkbox and then delete the templates.

Feature request

I would like to have an implementation of `AsyncMysqlQueryErrorResult` and `SQLFakeAsyncMysqlException` that behaves similarly to `AsyncMysqlException`. 
This is an SQL/AsyncMysql feature.

`AsyncMysqlQueryErrorResult` should allow for setting the error code and error message of the result in its constructor.
`SQLFakeAsyncMysqlException` should allow for setting the `AsyncMysqlErrorResult` in its constructor.

Question: Parser does not know about some Operators

Issue template for hack-sql-fake

  • [ X ] Question

Question

QQ: I took a Keyset\diff of Operator::getValues() and SQLParser::OPERATORS. There are some operators that the parser does not know about that do have an implementation in the rest of the code. Think of RLIKE. Others are only used in this block.

      case Operator::ANY: // parser does NOT KNOW about this functionality
      case Operator::SOME: // parser does NOT KNOW about this functionality
      //[[fallthrough]] <- note to humans, not to the typechecker, therefore different syntax.
      default:
        throw new SQLFakeRuntimeException("Operator {$this->operator} not implemented in SQLFake");

For maintainability I would like to end up with declaring the enum only once. This will require some filtering on the SQLParser constant. This will nolonger allow it to be a constant. Could something like this be done in the future?

class SQLParser{
  visibility static function getParsableOperators(): keyset<Operator>{
    return Keyset\filter(Operator::getValues(), $op ==> self::isImplemented($op));
  }
}

AsyncMysqlQueryResult::mapRows() returns NULL as ""

This line makes all the return values strings, even the NULL values. https://github.com/slackhq/hack-sql-fake/blob/master/src/AsyncMysql/AsyncMysqlQueryResult.php#L42
According to the documentation the return type should be Vector<Map<string, string>>, but that seems off. The HHI agrees with that too. However the documentation describes string|null.
https://docs.hhvm.com/hack/reference/class/AsyncMysqlQueryResult/mapRows/#examples

Are we sure the return type isn't secretly Map<string, ?string>?

Question: Is each TokenType as valid Operator?

Issue template for hack-sql-fake

  • [ X ] Question

Question

This line https://github.com/slackhq/hack-sql-fake/blob/master/src/Expressions/FunctionExpression.php#L21 takes a $this->type TokenType::enum and casts it to a string. It then assigns it to a property called $this->operator string. I presume that this property must have the type ?Operator::enum (new in #21). It seems very weird that these values are valid members of Operator::enum.

  • Should I add the to these values Operator::enum too? If no, what should I do with this assignment? HH_FIXME will be required.
  • If not, adding them to the Operator::enum will make the code less maintainable, since Hack does not support this.
enum ONE: int { ONE = 1; }
enum TWO_AND_ONE: int { use ONE; TWO = 2; }

TokenType for reference.

enum TokenType: string {
  NUMERIC_CONSTANT = "Number";
  STRING_CONSTANT = "String";
  CLAUSE = "Clause";
  OPERATOR = "Operator";
  RESERVED = "Reserved";
  PAREN = "Paren";
  SEPARATOR = "Separator";
  SQLFUNCTION = "Function";
  IDENTIFIER = "Identifier";
  NULL_CONSTANT = "Null";
}

LIKE queries do not work with plus signs

  • Feature request
  • Question
  • Suggestion
  • Typechecker errors
  • [X ] Incorrect result
  • Cripplingly bad performance
  • Crash

Incorrect result

The following example:
When doing an AND LIKE query with a plus sign (i.e AND LIKE '%foo+bar%') the plus sign is not escaped and the query does not work correctly.

I have a fix and will be opening a PR.

Question: Is queryf silently correcting mistakes considered a bug?

Issue template for hack-sql-fake

Please select the options that apply

  • Feature request
  • Question
  • Suggestion
  • Typechecker errors
  • Incorrect result
  • Cripplingly bad performance
  • Crash

Follow the template for your checked checkbox and then delete the templates.

Question

Would it be considered a bug if the queryf implementation of SQL Fake silently "corrects" errors which cause the real queryf to throw? A lot of strict validation is missing from the SQL Fake implementation and I would love to make it as strict as the real queryf. For example SELECT "hi" throws in the real queryf.

I would love to submit a PR aligning queryf with queryf. This would break BC left, right, and center. But I believe this would be for the better. Would this be appreciated?

Support correlated subqueries

Where the row from the main query is referenced inside a subquery, like this:

SELECT * FROM table1 a WHERE NOT EXISTS (SELECT * FROM table2 WHERE a.id = table_1_id)

Loosen the strict version requirement on HHAST.

Composer.json requires the exact HHAST version 4.0.4 by using an =4.0.4 version. This blocks the autoload map generation with an exception. If this could be made looser ^4.0.4 the autoload map can be generated again. The typechecker would be happy too.

Question: Are the undocumented formatting modifiers used?

Issue template for hack-sql-fake

Please select the options that apply

  • Feature request
  • Question
  • Suggestion
  • Typechecker errors
  • Incorrect result
  • Cripplingly bad performance
  • Crash

Follow the template for your checked checkbox and then delete the templates.

Question

The queryf implementation of SQL Fake implements modifiers that are not in Hack's hhi. Do you depend on these extra modifiers?

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.