Skip to content

NULL in select is escaped (mysqli_sql_exception) #1169

Description

@fefo-p

When trying to get a field that does not exist in a table, I get an Unknown column 'NULL' in 'field list' error.
As you can see below, it seems that BaseBuilder is not taking into account that NULL is not a field (then backticks are not needed).

My function is:

  public function joinExpedientes() {
        return $this->select('NULL as fecha_salida')
                    ->join('expedientes', 'movimientos_entradas.id_expediente = expedientes.id_expediente');
    }

And what BaseBuilder gets is:

SELECT `NULL` as `fecha_salida`
FROM `movimientos_entradas`
JOIN `expedientes` ON `movimientos_entradas`.`id_expediente` = `expedientes`.`id_expediente`

Obviously, when you try this select (without the backticks) in MySQL, it works fine.
Maybe there is a way to escape NULL in active record select, but if that's the case, I do not know how.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions