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

Don't change table names #117

Closed
bkniffler opened this issue Jan 30, 2019 · 4 comments

Comments

Projects
None yet
2 participants
@bkniffler
Copy link
Contributor

commented Jan 30, 2019

Is your feature request related to a problem? Please describe.
Table will be stored with a seemingly random id instead of the actual tableName. I'm not sure why this is done, but it makes reading the database very difficult. This is especially bad if I want to run another system over the database that does not use nano-sql.

Describe the solution you'd like
A configuration flag to disable that behavior.

@ClickSimply

This comment has been minimized.

Copy link
Owner

commented Jan 31, 2019

Added a new filter that lets you do this.

nSQL().connect({
    tables: [...],
    plugins: [
        {
            name: "My Plugin",
            version: 1.0,
            dependencies: {},
            filters: [
                {
                    name: "configTableSystem",
                    priority: 1000,
                    call: (inputArgs: {res: InanoSQLTable, query: InanoSQLQuery}, complete, cancel) => {
                        inputArgs.res.id = inputArgs.res.name;
                        complete(inputArgs)
                    }
                }
            ]
        }
    ]
})

I didn't want to add a config option since this breaks the behavior of alter table queries. Since a unique id is generated for tables instead of using the table name, you can change your table names whenever you'd like. Once you setup this in your plugin you won't have that capability anymore.

The filter should be live in 2.1.3

@bkniffler

This comment has been minimized.

Copy link
Contributor Author

commented Jan 31, 2019

I've done as advised. The method is called, but the names are still random :(

@bkniffler

This comment has been minimized.

Copy link
Contributor Author

commented Jan 31, 2019


      {
        name: 'originalTableNames',
        version: 1.0,
        dependencies: {},
        filters: [
          {
            name: 'configTableSystem',
            priority: 1000,
            call: (inputArgs, complete, cancel) => {
              console.log(inputArgs.res.name, inputArgs.res.id);
              inputArgs.res.id = inputArgs.res.name;
              complete(inputArgs);
            }
          }
        ]
      }
@ClickSimply

This comment has been minimized.

Copy link
Owner

commented Jan 31, 2019

Install 2.1.4, should resolve this issue.

@bkniffler bkniffler closed this Jan 31, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.