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

Can not insert with value = null #150

Open
phuc49 opened this issue Nov 17, 2023 · 2 comments
Open

Can not insert with value = null #150

phuc49 opened this issue Nov 17, 2023 · 2 comments

Comments

@phuc49
Copy link

phuc49 commented Nov 17, 2023

static mapRowAsObject(fieldList, row) {
	return fieldList
		.map(f => {
			return encodeValue(false, row[f] != null ? row[f] : '', 'TabSeparated');
		})
		.join('\t');
}

if value = null why dont insert that null value to db

@Blaumaus
Copy link

Maybe try inserting it as a 'NULL' string?
Here's a simplified approach on how I did it in my app:

const dto = (
  psid: string,
  // ....
): Array<string | number> => {
  return [
    psid,
    ....
  ]

// call it like
dto(params.psid)

// or
dto('NULL')
}

then you can save it like:

const query = `INSERT INTO table (*) VALUES ${_join(data, ',')}`
      try {
        await clickhouse.query(query).toPromise()
      } catch (e) {
        console.error(`[CRON WORKER] Error whilst saving log data: ${e}`)
      }

@Blaumaus
Copy link

and eventually it should store the data as null:
Screenshot 2023-12-16 at 20 50 34

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

No branches or pull requests

2 participants