Giter VIP home page Giter VIP logo

Comments (8)

piotr-cz avatar piotr-cz commented on August 21, 2024

Was there a wp_users table in your database before running second query?

As for creating tables on the fly

I've decided to create collection tables on the fly, because it's cleaner and at first seemed cheaper than in every method (find/ insert/ delete/ count).

My assumption was that if developer decides to operate on collection/ table, he/ she is sure it exists.

Probably this could be refactored with a cached table exists check on every read type operation and create table on write type,

from cockpit-sql-driver.

raffaelj avatar raffaelj commented on August 21, 2024

Was there a wp_users table in your database before running second query?

Yes. I tested it with a WordPress installation in the same database. I know, it's better to use different hosts and databases per app, but people do such things. Especially in the WordPress world with the cheapest web hoster possible, where a second database costs extra money.

Well, ... and I'm working on a Cockpit implementation as a WordPress plugin...

My assumption was that if developer decides to operate on collection/ table, he/ she is sure it exists.

If we ignore typos and tests with wrong methods while getting started with Cockpit, there is still the possibility, that a different addon author uses a table name, that exists already in my database. A table prefix would eliminate these conflicts.

Probably this could be refactored with a cached table exists check on every read type operation and create table on write type,

That sounds nice, but I think, it behaves like the SQLite driver right now. If I remember correctly, that one creates empty tables on read requests on the fly, too.

from cockpit-sql-driver.

piotr-cz avatar piotr-cz commented on August 21, 2024

I'll prepare table prefix feature and let's leave table checks for other time as it's separate issue

from cockpit-sql-driver.

piotr-cz avatar piotr-cz commented on August 21, 2024

Could you test feature in #7?

from cockpit-sql-driver.

raffaelj avatar raffaelj commented on August 21, 2024

It seems, like nothing has changed. I guess, you have to add the prefix to the query builder, too.

from cockpit-sql-driver.

raffaelj avatar raffaelj commented on August 21, 2024

Sorry, my fault. I renamed the old SqlDriver module instead of deleting it and copied the fork, so it was loaded before the replacemant fired. Stupid mistake :D

So it seems to work with the prefix.
After creating a test entry in a test collection, I have these new databases:

cp_cockpit/accounts
cp_cockpit/options
cp_cockpit/revisions
cp_collections/test

And this one created a new table cp_test:

$this->on('cockpit.bootstrap', function() {
    $test = $this->storage->getKey('test', 'test', []);
    var_dump($test); // array(0) { } 
});

Thank you very much for that fast fix.

from cockpit-sql-driver.

raffaelj avatar raffaelj commented on August 21, 2024

After some more tests, it looks very promising. I added an asset and a singleton via Cockpit UI, I sent a message with a contact form from the WordPress frontend and it was successfully stored. Now my database looks much cleaner than before.

screenshot_wp_cp_sql-driver

from cockpit-sql-driver.

piotr-cz avatar piotr-cz commented on August 21, 2024

Let's continue thread on on #7

from cockpit-sql-driver.

Related Issues (6)

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.