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

Redesign metadata and Query Builder #31

Merged
merged 15 commits into from
Apr 2, 2017

Commits on Mar 28, 2017

  1. Use underscore functions for Trans metadata

    When a module uses `Trans`, two underscore functions will be added to provide
    the necessary metadata for the `Trans.QueryBuilder` and `Trans.Translator`
    functions.
    
    This underscore functions are:
    - `__trans__(:container)`, which returns the name of the translation container field.
    - `__trans__(:fields)`, which returns a list of the translatable fields.
    crbelaus committed Mar 28, 2017
    Configuration menu
    Copy the full SHA
    2ee5a22 View commit details
    Browse the repository at this point in the history

Commits on Mar 29, 2017

  1. Configuration menu
    Copy the full SHA
    511b4ee View commit details
    Browse the repository at this point in the history

Commits on Mar 30, 2017

  1. Remove translation container customization

    The translation container customization allowed users to declare an
    alternative field (the default was `:translations`) as the field that
    contained the translations for the schema.
    
    This customization has been sacrificed to ease the rewrite of the
    QueryBuilder module. Now, Trans will always look in the `:translations`
    field and there is no way to customize it.
    crbelaus committed Mar 30, 2017
    Configuration menu
    Copy the full SHA
    f0c1d0c View commit details
    Browse the repository at this point in the history
  2. Refactor QueryBuilder module

    All the functions of the `Trans.QueryBuilder` module have been removed
    and replaced with the macro `translated/2`. This macro generates
    an SQL Fragment and can be directly used from inside an `Ecto.Query`.
    
    This removes the necessity of building the query before calling the
    `Trans.QueryBuilder` functions and integrates seamelessly with
    `Ecto.Query` provided functions for comparisons, etc.
    This also permits adding conditions on joined schemas.
    crbelaus committed Mar 30, 2017
    Configuration menu
    Copy the full SHA
    b68fb7f View commit details
    Browse the repository at this point in the history
  3. Update QueryBuilder tests with new query syntax

    The QueryBuilder tests have been updated to use the newly introduced
    `translated` macro.
    crbelaus committed Mar 30, 2017
    Configuration menu
    Copy the full SHA
    a682ec1 View commit details
    Browse the repository at this point in the history

Commits on Mar 31, 2017

  1. Update Translator module

    The translator module does not require to be passed the name of the
    translation container field. The test have also been updated to reflect
    this change.
    crbelaus committed Mar 31, 2017
    Configuration menu
    Copy the full SHA
    69285e0 View commit details
    Browse the repository at this point in the history
  2. Fix PostgreSQL JSONB operators precedence errors

    In PostgreSQL 9.4 [1] the operators had different precedence rules than in
    PostgreSQL 9.5 or higher [2] (take a look at "any other operator" in the table.
    
    This differences caused errors when triggering a query that contained something
    similar to `where a->b is not null`, which 9.4 would interpret as
    `where a->(b is not null)` and 9.5 or higher would interpret as
    `where (a->b) is not null`.
    
    This commits adds parentheses around the JSONB accesses to avoid this kind of
    problems by stating the desired preference explicitly.
    
    [1] https://www.postgresql.org/docs/9.4/static/sql-syntax-lexical.html
    [2] https://www.postgresql.org/docs/9.5/static/sql-syntax-lexical.html
    crbelaus committed Mar 31, 2017
    Configuration menu
    Copy the full SHA
    1c9a8e3 View commit details
    Browse the repository at this point in the history
  3. Remove unused import

    crbelaus committed Mar 31, 2017
    Configuration menu
    Copy the full SHA
    e8d0d20 View commit details
    Browse the repository at this point in the history

Commits on Apr 1, 2017

  1. Improve Trans usage and docs

    Options provided when using `Trans` are now stored into a module
    attribute.
    crbelaus committed Apr 1, 2017
    Configuration menu
    Copy the full SHA
    bbb905e View commit details
    Browse the repository at this point in the history
  2. Validate translatable fields during compilation

    `Trans` will validate the fields declared as translatable and raise an
    error during compilation time if they are not declared in the module's
    struct or schema definition.
    crbelaus committed Apr 1, 2017
    Configuration menu
    Copy the full SHA
    92d305b View commit details
    Browse the repository at this point in the history
  3. Validate translated field in Trans.Translator

    Trans.Translator now validates that whether the field is translatable and
    provides a useful error message instead of the default `KeyError`.
    
    Docs have been updated and typespecs added.
    crbelaus committed Apr 1, 2017
    Configuration menu
    Copy the full SHA
    4b0e5fd View commit details
    Browse the repository at this point in the history

Commits on Apr 2, 2017

  1. Check whether a field is translatable or not

    The function `Trans.translatable?/2` checks whether a field is
    translatable or not.
    crbelaus committed Apr 2, 2017
    Configuration menu
    Copy the full SHA
    d02711d View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    c1c333f View commit details
    Browse the repository at this point in the history
  3. Validate translated conditions in compile time

    The macro `Trans.QueryBuilder.translated/3` now validates the translated
    fields before the macro expansion step. We will receive an error in
    compilation time when adding conditions on untranslatable fields.
    crbelaus committed Apr 2, 2017
    Configuration menu
    Copy the full SHA
    cbb6ba1 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    e51689c View commit details
    Browse the repository at this point in the history