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

MySQL string comparison limitation could break some backend operation #356

Open
j-maxi opened this issue Jan 17, 2017 · 1 comment
Open
Labels

Comments

@j-maxi
Copy link

j-maxi commented Jan 17, 2017

According to MySQL spec (limitation), MySQL VARCHAR ignores trailing spaces on string comparison.
http://dev.mysql.com/doc/refman/5.7/en/char.html

MySQL collations are of type PADSPACE. This means that all CHAR, VARCHAR, and TEXT values in MySQL are compared without regard to any trailing spaces.

Also, the comparison is not case sensitive.
http://dev.mysql.com/doc/refman/5.7/en/case-sensitivity.html

Using MySQL as a DB and having "relation" between two resources in gohan schema, we rely on MySQL's foreign key constraint for validation. With the above limitation, I realized that resource relation could be created with case insensitive manner or ignoring trailing spaces. If we have some backend which resolves resource relation in strict string comparison, the backend cannot find the proper relation and could fail.

For example, if we have a schema like below, we can create resources customer.id = "abc" and device.customer_id = "ABC ". And as a results, backend operation will fail if it tried to resolve customer resource from device.customer_id with strict string comparison.

schemas:
- id: customer
  plural: customers
  schema:
      id:
        permission:
        - create
        type: string
    propertiesOrder:
    - id
    required:
    - id
    type: object
  singular: customer
  title: Customers
- description: Devices
  id: device
  plural: devices
  schema:
    properties:
      customer_id:
        permission:
        - create
        relation: customer
        type: string
        unique: false
      name:
        permission:
        - create
        - update
        type: string
    propertiesOrder:
    - name
    - customer_id
    required:
    - customer_id
    type: object
  singular: device
  title: Devices
@nati nati added the bug label Jan 23, 2017
@j-maxi
Copy link
Author

j-maxi commented Feb 2, 2017

@nati cc: @marcin-ptaszynski @morrisson
Do you have any idea on solving this issue?

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

No branches or pull requests

2 participants