Firebase Multi-database rules 'root' value issue - database

I'm using Firebase in my app that utilizes the new Multi-database feature. But, while setting up the rules, I noticed one annoying problem: the 'root' variable in the database rules is returning a RuleDataSnapshot of the primary database and not a RuleDataSnapshot of the secondary database the rules are attached to.
This is a huge problem for me because I have a few constant values in the secondary database that I need to reference in the rules. Because I'm planning to use this method to scale up, I don't want to have to try sorting and remapping these constants to the main database.
Thanks -Nathan

Okay! I found out that this was only happening in the simulator. I tested it live and it seemed to work properly. Definitely submitting this as a bug report. Thanks to anyone who started to check into this!

Related

Yii2 Giving ActiveRecord Model Database Details on Construction

I am construction a login system for Yii2 that can create the identity from either within a table in the Yii2 application or from data from an external database, the data could reside in one of many, many databases.
I know i could setup second, third, fourth databases in the apps config, but it doesn't fit the use case as, as the database belongs to a user who could change it, etc.
What i need to do it instantiate an ActiveRecord model passing it the database details of the database it should connect to, to query.
I have managed to very much confuse myself over this, in trying to work out the correct way to do it.
I know you can pass a config array to the constructor, but am unable to understand how i should do it, should i create and object of \yii\db\connection and pass it to the __construct?
If so how do i then perform the connection ?
I have searched all over for similar use case, but am unable to discover anything that helps, even a pointer would be great.
Many Thanks
Ok, so after so more head banging and searching in a different way, i have discovered a very simple and sensible approach, and the answer does come from SO.
Yii2 set db connection at runtime

Create does not work in GAE Datastore viewer

When I try to create some entities I don't see the option to input fields. I just see the SaveEntity button.
However I can view all the existing entities.
What is very strange is - there is another entity called VideoEntity for which the create did not work yesterday but works today.
Can somebody help me with this seemingly unpredictable tool ?
Regards,
Sathya
i think the console knows what properties each entity has based on existing data, rather then your models. and the data is only updated periodically. when did you upload your app? maybe waiting a few hours will give the console time to update.
alternatively, you could use the remote api to add your entities, or write a small snippet and upload such as ...
VideoStatsEntity(app='home', ip='116.89.52.67', params='tag=20130210').put()
Writing a simple interface to the data-store to allow you to edit/create models is probably the best thing to do in this case. You know what they contain so you can adjust your interface accordingly, rather then waiting for the admin interface to "catch up" as Gwyn notes.
I believe that there are some property types that are impossible to add via the admin interface that you are using so you'll probably get to the point sooner rather then later of creating a custom interface.
The admin datastore view is good for quickly checking out the contents of the datastore, but ever tried paging through 100's of entries? Not fun.

How to get Web2py Table Migration in Google App Engine to work?

I've been using web2py for a few years, but just starting with deploying to GAE.
I was able to get a simple web2py application running on GAE, then made some modifications which included schema modifications. I started getting weird errors (an insert failed because a field needed to be a float, when it was explicitly set to be a float constant), and it looks like the schema modifications were not carried out in GAE -- a check of the datastore shows entities w/ the old schema (for example, my problematic float-field is missing). These migrations worked fine locally (using SQLite).
settings.migrate is set to True, and all tables have migrate set to that value.
Not sure what code I could provide that would be helpful; all define_table calls are pretty standard.
As for the question(s):
What, if anything, do I need to do to make these migrations work? If it involves removing the current Entities for my tables (so new ones, with the right schemas, can be created), how would I go about doing that? (My Datastore Admin page is completely blank.) Might this be related to the fact that trying to truncate a table on GAE fails?
The problem was solved by changing the new fields from floats to doubles; not sure where (web2py or GAE, or the interface between the two) the issue w/ floats came from, but this was an easy way to route around it.

Databases and Qt

I am building an application in Qt/QML.
I have a table view of the database (PostgreSQL).
Is there a way to dynamically refresh my table if there is any change in the database.
One no-so-efficient way to do it is to keep sending periodic SQL queries.
Is there any automatic way to keep my view refreshed?
I am open to use any other Database also if required.
Qt seems to support the NOTIFY mechanism of PostgreSQL databases. Googling for it it found some bug reports, so not sure of well implemented that is. Since I've never used it, I'll have to refer you to google.
If you use QSqlTableModel (or an editable subclass of QSqlQueryModel) with QTableView, any edits made will immediately be visible.

Database and version control system

I'm work on project with django framework and use control version system to synchronize my code with other peoples. But i don't know how organize work with database.
In django, any people, worked on project, may changes django models, and tell 'syncdb' to synchronize model objects with db.
But other people don't about this changes, and it's code revision may not works.
Please, tell me some ways to solve this problem (maybe, different db or something another).
Thanks, and excuse my english :)
You have to actually talk to the people on your project.
If someone changes any database model, they have to actually tell everyone else about the change. This is not a Django problem.
Think of any SQL database -- without Django. When the DBA drop's a table, they have to tell everyone that they changed the database. Otherwise all programs that use the table break.
The model definition is special, and whoever can change this must tell everyone else.
You must have an initial backup of the DB under verison control. And after that you have to put all the modification scripts on the same version control. Something like this:
/Database (in the repository)
Initial backup
Script1_date.sql
Script2_date.sql
...
I'm not sure to understand your problem; but remember that on Django, syncdb only creates new tables. It doesn't alter an existing table.
If, for example you just add a new field, a syncdb won't do anything.
Actually, looking at the alternatives, I'm often surprised that nobody mentions South
http://south.aeracode.org/
It seems to be the best migration app out there... perhaps I am missing something important, but I find it pretty nice to work with...
take also a look at deltasql.
you can test it at http://www.gpu-grid.net/deltasql (username: admin password: testdbsync )
and download from http://sourceforge.net/projects/deltasql
ciao :-)
I'm curious...what happens if you put your MDF and LDF files under source control? Of course if your tables are empty and you just have the structure of the database...
Sounds like you want migrations.
As an example:
http://www.aswmc.com/dbmigration/
You may also want to add functional unit tests that actually test that the schema is as expected, that way when the tests fail, you can see that it is a schema change, and audit whether it will affect other parts of the app. If it doesn't, fix your test to take into account the new schema.

Resources