Skip to content

migration batchInsert can't handle NULL in .dat files #988

@marcelloh

Description

@marcelloh

if we use a .dat file with null values, like this:
1,1,superadmin,"First name Last name",[email protected],,NULL,NULL
the NULL's are imported as strings and become "NULL"

this is wrong.

Expected Behavior

Have one record in the database with 2 columns with a NULL value

Workaround

We have a self written batchInsert that is almost the same, except for the value part:

$values = array_map(
	function ($value) {
		return 'null' === strtolower($value) ? null : $value;
	},
	$line
);

output

INSERT INTO "users" ("id", "login_type_id", "username", "name", "email_addr", "password", "phone_num", "token_id") VALUES (?, ?, ?, ?, ?, null, ?, ?)ERROR: SQLSTATE[22P02]: Invalid text representation: 7 ERROR:  invalid input syntax for integer: "NULL"

Details

Phalcon DevTools (3.0.5)

Environment::
  OS: Linux 273379e6b838 4.9.12-moby #1 SMP Tue Feb 28 12:11:36 UTC 2017 x86_64
  PHP Version: 7.0.16-4+deb.sury.org~xenial+1
  PHP SAPI: cli
  PHP Bin: /usr/bin/php7.0
  PHP Extension Dir: /usr/lib/php/20151012
  PHP Bin Dir: /usr/bin
  Loaded PHP config: /etc/php/7.0/cli/php.ini
Versions::
  Phalcon DevTools Version: 3.0.5
  Phalcon Version: 3.0.4
  AdminLTE Version: 2.3.6
Database : Postgress

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions