Giter Club home page Giter Club logo

knex-stringcase's People

Contributors

kequc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

knex-stringcase's Issues

Bug: columns are not becomes camelCase at 1.1.0

Hi,

I've updated to the latest version (1.1.0), and now the columns names are not converting to camelCase at all.

I've debugged it a bit, looks like this line always false cause the object that knex returns has TextRow as a constructor.

image

Looks like this data type is what mysql2 returns, therefore the check for constructor is invalid.

When writing queries using pure knex.raw() statements results are not camelcased

Hi again,

I'm mostly looking for confirmation here regarding knex-stringcase whether it definitively converts pure knex.raw() queries to camelcase.

For the local testing I've worked through after pulling knex-stringcase into our project we can clearly see that one knex query which uses knex('table_name').select('column_one', 'column_two') returns the field names as camelcase, yet when using the exact same query but with knex.raw('select column_one, column_two from table_name') any field names returned are in snakecase.

The team and I here are wondering if this a bug or is this by design?

Expected results:
When using pure knex.raw('select column_one, column_two from table_name') queries the field names are returned as camelcase

Actual results:
When using pure knex.raw('select column_one, column_two from table_name') queries the field names are returned as snakecase

Versions:

  • knex-stringcase: 1.4.6
  • knex: 1.0.3
  • postgresql v13
  • node-postgres: 8.7.3
  • node: 16.13.1
  • npm: 8.1.2

Create TypeScript definitions

First of all, thanks for the module.

It would be good to create TypeScript definitions for this.

Happy to contribute.

1.0.0 -> 1.0.1 processing of dates

With 1.0.0, timestamptz columns returned an instance of Date, but with 1.0.1, they return a plain object. For now, I am pinning to 1.0.0.


1.0.0

console.log(lastItem.createdAt);

2018-12-05T16:16:01.841Z 

console.log(typeof lastItem.createdAt);

object

console.log(lastItem.createdAt instanceof Date);

true

1.0.1

console.log(lastItem.createdAt);

{}

console.log(typeof lastItem.createdAt);

object

console.log(lastItem.createdAt instanceof Date);

false

My package.json includes:

    "pg": "^7.8.2",
    "knex": "^0.16.3",
    "knex-stringcase": "1.0.1",

Converting jsonb object keys into camelcase

I have a jsonb column which I insert an object {"foo_bar": "bar_foo"} into.

The representation in the postgres database is {"foo_bar": "bar_foo"} but when I pull the value out using knex and knex-stringcase, the object key gets converted to camelcase and I end up with {"fooBar": "bar_foo"}.

The value does not change, only the key.

Is this intended to be the expected behavior?

I am using

knex v0.16.5
knex-stringcase v1.3.0
postgres 9.6.16

How to stop converting table name?

I love this plugin but I have a problem with it converting table names such as "order-rows_fields" to "order_rows_fields".
Is there a way to stop this for table names but keep it for column names?

v1.2.0 is not backward compatible with v1.1.x

Hi. I found that v1.2.0 is not backward compatible with v.1.1.x. When I try to build and run my project, the following error is being thrown.

"Cannot find module './build-converter.js'".

Thanks.

Way to ignore built in columns

Hi,

Knex internally has some times (at migrations) usage of internal tables (such as information_schema).
Those builtin tables has special cases (CONST_CASE), and because of the casting, knex fails on migrations. (trying to access TABLE_NAME) but the object is camelCased.

There is any why to ignore those built in tables?

Disable knex-stringcase for specific query

Is it possible to disable knex-stringcase for specific query?
ignoreStringcase is not an option for me, cause I need raw column names only for one specific query, and convert this column names to camelCase in another queries.

Table identifiers vs column identifiers

Hi!

I have a very old specific database and was wondering whether it would be possible to discern between table names and column names namely I don't want my column names converted to upper case snake case, while I do want that for my columns. Would there be any way of achievingthis?

Thanks for the help!

Not working properly for sqlite3 in-memory DB

Hi, I've encountered a problem when using knexStringcase for sqlite3 in-memory db, the property Key is not parsed from snake case to camel case.

  db = Knex(
    knexStringcase({
      client: "sqlite3",
      connection: {
        filename: ":memory:",
      },
    })
  );

const result = db(table)
      .select("*")
      .where(where)
      ...

console.log(result[0]);

I got:

{
    id: '00000000-0000-0000-0000-000000000003',
    tenant_id: '94463c40-8e56-4afd-bee5-d2eda624bee9',
    created_at: 1584368640000
}

It works correctly when using a real postgres DB

Snakecase field names containing a number are not fully converted to camelcase

Hi there,

We've recently pulled knex-stringcase into a project of ours and are enjoying it so far, with a couple oddities discovered.

The one I'm raising here is with respect to field names which include numbers in them. It appears as though if an underscore appears before a number then the underscore is not removed - although the rest of the string is snake to camel converted.

Expected results:
address_line_1 is changed to addressLine1

Actual results:
address_line_1 is changed to addressLine_1

Internally our app and API has addressLine1 defined for all our schemas. Our database as you can expect uses snakecase everywhere.

Versions:

  • knex-stringcase: 1.4.6
  • knex: 1.0.3
  • postgresql v13
  • node-postgres: 8.7.3
  • node: 16.13.1
  • npm: 8.1.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.