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

pg adapter leaks symbols in rows #137

Closed
gabssnake opened this issue Jul 12, 2021 · 7 comments
Closed

pg adapter leaks symbols in rows #137

gabssnake opened this issue Jul 12, 2021 · 7 comments

Comments

@gabssnake
Copy link

Hello again,
We noticed that rows being return from pg adapter queries include Symbol(_id).
This is mostly aesthetic, but can be confusing. I'll be happy try a PR, do you have any pointers ?
Best,

// pg-mem/src/tests/pg.spec.ts

it('does not leak symbol properties in rows', async () => {
    simpleDb();
    const { Client } = db.adapters.createPg();
    const client = new Client();
    await client.connect();

    many(`create table mytable (msg varchar);
        insert into mytable values ('hello'), ('hi');`);

    const got = await client.query('select * from mytable;');

    // fails
    expect(Object.getOwnPropertySymbols(got.rows[0]).length).to.be.equal(0);

    await client.end();
});
@oguimbal
Copy link
Owner

I guess that you could clone the results using somehting like Object.fromEntries(Object.entries(myRow)) in adaptResults() to get rid of the symbols

gabssnake pushed a commit to gabssnake/pg-mem that referenced this issue Jul 13, 2021
@gabssnake
Copy link
Author

There it goes :-)

gabssnake pushed a commit to gabssnake/pg-mem that referenced this issue Jul 13, 2021
gabssnake pushed a commit to gabssnake/pg-mem that referenced this issue Jul 13, 2021
@gabssnake
Copy link
Author

unfortunately, had to revert the usage of Object.fromEntries because tests fail on node 10.x

@A7med-Ragheb
Copy link

Hi @gabssnake @oguimbal,
Kindly, do you have an update regarding this issue? Are you working on another fix?

@oguimbal
Copy link
Owner

This fix is merged, but not yet shipped in the latest version.

That said, I fail to see how those attached symbols are annoying... They are almost transparent, arent they?

@A7med-Ragheb
Copy link

A7med-Ragheb commented Jul 17, 2021

@oguimbal It is annoying as I'm using this library for my unit tests to test the repository layer in my application and I want to compare the returned results from DB with the expected results and this is always failing as there are two extra values I didn't add them in my table.

Kindly, When it will be shipped to the latest version?

@oguimbal
Copy link
Owner

@A7med-Ragheb this shipped with pg-mem@1.9.12

sambacha pushed a commit to sambacha/pg-mem that referenced this issue Aug 14, 2021
* parser cache

* Build deno

* Fix published types

* Create LICENSE

* Handle extensions + custom functions + a bit of cleaning/refactoring

* Fix current_schema

* Better functions extensibility

* Version bump

* Build deno

* udpate readme

* update readme

* Fix

* Build deno

* fix

* Build deno

* Better errors & constraints handling, valued keywords, fixes.

* Add unit tests + upgrade pgsql-ast-parser

* Fix UTs

* Support drop statements

* Sequence UTs (failing)

* Work on regclass

* Fix & add tests

* Fix regclass

* Fix typeorm

* add some UTs

* bytea + time + restore true casing

* Fix some tests

* fix casing

* Bump

* fix readme

* Build deno

* fix

* Better error reporting

* assimilate oid to int, and support newer versions of typeorm

* Add mirrobytes sample

* db.migrate() from node-sqlite

* add ci

* Update main.yml

* Truncate + on delete XXX behaviour + fixes

* Fixes

* Build deno

* Create codeql-analysis.yml

* tweak

* Fix unhandled rejection warns

* Build deno

* Implement geometric types

* Build deno

* Generated columns + stub support for "match" on foreign keys

oguimbal#9

* support identites on table creation

* Build deno

* Work on custom types

* Work on custom types

* Work on custom types (full typesystem refactoring)

* Fix custom enums uts

* Build deno

* fix timestamp

oguimbal#12

* Fix node-postgres adapter

* Support "overriding" in inserts

oguimbal#15

* Handle distinct

* Support knex.js

oguimbal#13

* Support sequelize

oguimbal#13

* Support values tables

* implement "with" statement

* Support "union" statement

* Fix union

* support "show" & "set" + add pg_range table

* Bump version

* Fix aggregate count on empty selection

* Build deno

* Update readme.md

* Update readme.md

* Update readme.md

* Update readme.md

* Update CONTRIBUTING.md

* Update readme.md

* Update readme.md

* Update readme.md

* public table insert&find + default value fix

* Build deno

* Remove pg-promise hack

vitaly-t/pg-promise#743

* Build deno

* Typo

* Update CONTRIBUTING.md

* Messy commit

* remove sql reconstitution in IValue

* Implement intervals + extract()

oguimbal#40

* Fixes

* Record data type

* Record selection on joins

* Prevent "record" columns

* Add UTs

* Add unit tests

* Update CONTRIBUTING.md

* Support INET type

oguimbal#49

* Support raw arrays statement & fix pg

oguimbal#50

* Support substring & overlay syntaxes

* ignore some unit tests (pending issues) + fixes

* Build deno [autogenerated commit]

* Fix create schema

* Build deno [autogenerated commit]

* Support min/max

* Build deno [autogenerated commit]

* Implement count(distinct) + refactor a bit ordering on jsons

oguimbal/pgsql-ast-parser#12

* Build deno [autogenerated commit]

* Move things & some cleanup

* add some UT to fix

* Support "create functions" & "do" statements with custom compilers.

oguimbal#42

* Build deno [autogenerated commit]

* fix: more sustainable compiler api

* Build deno [autogenerated commit]

* add kind-of-plv8 unit test

* Add files via upload

* Update readme.md

* Fix create unique index

oguimbal#55

* Build deno [autogenerated commit]

* fix UT

oguimbal#55

* fix problems with nil jsonb results

* Support "insert into select" statements

oguimbal#35

* Fix edge cases

* Build deno [autogenerated commit]

* fixed typeorm version

* fix: avoid calling when null arguments (unless accepts explicitely)

* Added SUM and SUM(DISTINCT) aggregators

* formatting

* fix two typos

* Bump version

* Build deno [autogenerated commit]

* fix so undefined => 'null' instead of an error

* bump version

* Build deno [autogenerated commit]

* Fix "create index if not exists"

closes oguimbal#66

* Fix self-referencing tables on creation

closes oguimbal#65

* Fix empty arrays + bump ast-parser

closes oguimbal#64

* Fix build

* Version bump

* Build deno [autogenerated commit]

* Fixed typo in timestamptz support

* Added expression test covering the use of timestamptz

* Bump

* Build deno [autogenerated commit]

* fix: TimestampType.doEquals

The Equality operator must use the absolute value of the difference

oguimbal#71

* Bump

* Build deno [autogenerated commit]

* Use refactored pgsql-ast-parser@6 + fix case-sensitive bugs

* Fix qualified aggregation functions

* registerEquivalentType()

oguimbal#75

* Build deno [autogenerated commit]

* improve readme

* Fix implicit casts on index lookups

oguimbal#69

* Build deno [autogenerated commit]

* Fix typos

* Fix nasty silent discrepancy with pg

# oguimbal#80

* add ut

* Build deno [autogenerated commit]

* Add unit tests (failing)

* Major pgsql-ast-parser version upgrade

* Refactor JOIN a bit

oguimbal/pgsql-ast-parser#30

* Refactor JOIN a bit

oguimbal/pgsql-ast-parser#30

* fix

* add ut

* Fixes + json null implementation leak

* Build deno [autogenerated commit]

* location tracking

* Fix leaky implementation details

oguimbal#84

* Build deno [autogenerated commit]

* Fix "SHOW" statement

oguimbal#88

* Build deno [autogenerated commit]

* Implement views

oguimbal#34

* bump version

* Build deno [autogenerated commit]

* Update package.json

* Views column names mapping

oguimbal#34

* add possible deps as optional peer dependencies

* Query interceptions

* Small fixes

* Support Mikro-orm

oguimbal#95

* Build deno [autogenerated commit]

* fix

* Build deno [autogenerated commit]

* Support at least independent inner requests (bugfix)

* Build deno [autogenerated commit]

* (regression) Fix select  "someAlias".*  on filtered statements

oguimbal#97

* Build deno [autogenerated commit]

* Fix drop column

oguimbal#96

* Build deno [autogenerated commit]

* Expose ISchema.getType() & IType.asArray()

oguimbal#99

* Build deno [autogenerated commit]

* Support schema definition with raw data type

oguimbal#99 (reply in thread)

* Build deno [autogenerated commit]

* Introduce the column manager for tables

Also remove columnDefs, which is replaceable with the columnManager

* fix type error + indentation

* update(adapters): add support to pass knexConfig

* tests: add test to validate knex config

* update: remove knex types to avoid bad DX

* bump

* Build deno [autogenerated commit]

* docs: fix contribuiting typo links

* docs: ajust link to ast-parser

* Add array_agg support

* Bump version

* Build deno [autogenerated commit]

* Add support of an avg function

* Also flag serial (autoincrement) when the type is bigserial

* Add test

* bump

* Build deno [autogenerated commit]

* feature/overlapOperator

* Fix some binary operator stuff

* Fix group-by on empty sets oguimbal#121

* Produce a PG unique_violation error

* fixes oguimbal#135, allowing insert empty arrays

* Bump version

* Build deno [autogenerated commit]

* fix release script

* Important quickfix OR/AND binary operator & null values oguimbal#138

* Build deno [autogenerated commit]

* fixes oguimbal#137, does not leak symbols in rows in pg adapter

* Version bump

* Build deno [autogenerated commit]

* Remove debugger

* Fix  oguimbal#146

* Build deno [autogenerated commit]

Co-authored-by: oguimbal <olivier.guimbal@gadz.org>
Co-authored-by: Olivier Guimbal <oguimbal@users.noreply.github.com>
Co-authored-by: Andrey Filatkin <anfilat@mail.ru>
Co-authored-by: maxvandongen <maxvandongen@yahoo.com>
Co-authored-by: Brahm Lower <bplower@gmail.com>
Co-authored-by: Cyrille Verrier <cyrille.verrier.external@arundo.com>
Co-authored-by: Karl Horky <karl.horky@gmail.com>
Co-authored-by: Vincent Lecrubier <vincent.lecrubier@gmail.com>
Co-authored-by: Florent FAYOLLE <florent.fayolle@stormshield.eu>
Co-authored-by: RafaelGSS <rafael.nunu@hotmail.com>
Co-authored-by: Ivan Matvieiev <ivan.matvieiev@bringg.com>
Co-authored-by: Jon Williams <jon@jonathannen.com>
Co-authored-by: bramkaashoek <bramkaashoek@gmail.com>
Co-authored-by: Clemens Zeidler <clemens.zeidler@smartparking.com>
Co-authored-by: Gabriel VIVAS <gabriel.vivas@stormshield.eu>
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

3 participants