How to Use a Table Prefix in Doctrine2's NamingStrategy Interface? - doctrine-orm

I want to duplicate our existing table structure, and we use table prefixes for all columns:
table name:
TBLO_TABLE_ONE
table columns:
TBLO_COLUMN_ONE
TBLO_COLUMN_TWO
etc...
However, the Doctrine Interface for NamingStrategy does not seem to accommodate. any ideas?

I've submitted a pull request to Doctrine2 github repository, adding this functionality.
https://github.com/doctrine/doctrine2/pull/357

Related

Duplicate value in column error - Azure Analysis Services

I have a table in my model which is extracting data from an adls location in Azure Datalake.
I am getting the following error while deploying the model:
'Column 'xy_id' in Table 'ABC' contains a duplicate value '' and this is not allowed for columns on the one side of a many-to-one relationship or for columns that are used as the primary key of a table.
I have checked the adls file for duplicates. There are no duplicate values. Also checked the count and distinct count in AAS which is same.
All the tables are getting processed successfully. The error comes on the "Deploy Metadata" step and the deployment fails.
There are only 3 tables in the model. I have created a One to Many relationship from table ABC to other 2 tables.
Can anyone suggest any fixes? I am not able to figure out why I am facing this error.
Thanks in advance.
You are interacting with different systems which stores data in different ways. By default Azure Analysis Services is case INsensitive.
This means that AAA and aAa are the exact same thing. Therefore, it will cause issues if:
the field is defined as Unique in AAS
the field is defined as Primary Key in AAS
the field is on the one-side of a one-to-many relationship
You can either solve this issue in the data source or change the database settings in SSMS.
However, as a general best-practice please define relationship only on integer fields. For example, you could create a Surrogate Key in the data source.

Creating tables with dynamic columns in apache calcite

There are two tables in graph database.
User { id, name}
Group { id, name}
User is connected to Group via an edge. No i want to query this via apache calcite with where clause as
select * from User where User.Group.id="Foo"
Since apache calcite accepts Schema with predefined Table with predefined columns, above query fails in validation step. One way to achieve this way is to Define user with Four columns as {id, name, Group.id, Group.name}. Now the problem is in my case, A table can be connected to more than one other tables and the depth can go up to 6 depth. Creating a table with all the columns of their child classes with lead to a table with lot of dynamic columns.
Is there a way to define columns of a table as the way they appear in query.
Look at resolved issue https://issues.apache.org/jira/browse/CALCITE-1150.
It introduces DynamicRecordType to Apache Calcite. Here is propossed specification https://docs.google.com/document/d/1vCWlqRyJQCtYbtVAjGOKP-8BD4_hrhoM9-4qbdoJs6k/edit.
I think it's used by Apache Drill project, see https://github.com/apache/drill/search?q=DynamicRecordType.

BigQuery Cannot Modify Partitioned Table Schema

Per the BigQuery documentation I am attempting to modify a table's schema by adding a field. The table in question is a partition slice (partitioned by day). I am planning on performing the action on every slice.
Per the documentation (https://cloud.google.com/bigquery/docs/managing-partitioned-tables), I should be able to add field to a partitioned table like any other table. However whenever I attempt to add a field to a partitioned table, I am met with this error:
Could not edit table schema.: Cannot change partitioned/clustered table to non partitioned/clustered table.
I am not able to find any good information on what this error means, or what I'm doing wrong. I have successfully added a field to a non-partitioned table. Does the community have any good ideas to help me troubleshoot?
I understand that you are using the update_table method to update the schema in python, correct me if I'm wrong. You have to do it with the patch API you can try this API to have a better view on how to do it.

How can I create a model with ActiveRecord capabilities but without an actual table behind?

I think this is a recurrent question in the Internet, but unfortunately I'm still unable to find a successful answer.
I'm using Ruby on Rails 4 and I would like to create a model that interfaces with a SQL query, not with an actual table in the database. For example, let's suppose I have two tables in my database: Questions and Answers. I want to make a report that contains statistics of both tables. For such purpose, I have a complex SQL statement that takes data from these tables to build up the statistics. However the SELECT used in the SQL statement does not directly take values from neither Answers nor Questions tables, but from nested SELECTs.
So far I've been able to create the StatItem model, without any migration, but when I try StatItem.find_by_sql("...nested selects...") the system complains about unexisting table stat_items in the database.
How can I create a model whose instance's data is retrieved from a complex query and not from a table? If it's not possible, I could create a temporary table to store the data in there. In such case, how can I tell the migration file to not create such table (it would be created by the query)?
How about creating a materialized view from your complex query and following this tutorial:
ActiveRecord + PostgreSQL Materialized Views
Michael Kohl and his proposal of materialized views has given me an idea, which I initially discarded because I wrongly thought that a single database connection could be shared by two processes, but after reading about how Rails processes requests, I think my solution is fine.
STEP 1 - Create the model without migration
rails g model StatItem --migration=false
STEP 2 - Create a temporary table called stat_items
#First, drop any existing table created by older requests (database connections are kept open by the server process(es).
ActiveRecord::Base.connection.execute('DROP TABLE IF EXISTS stat_items')
#Second, create the temporary table with the desired columns (notice: a dummy column called 'id:integer' should exist in the table)
ActiveRecord::Base.connection.execute('CREATE TEMP TABLE stat_items (id integer, ...)')
STEP 3 - Execute an SQL statement that inserts rows in stat_items
STEP 4 - Access the table using the model, as usual
For example:
StatItem.find_by_...
Any comments/improvements are highly appreciated.

Big table names in doctrine2

I have this "new" table in my database: event_comment_oauth_service which is an many-to-many relation table, between event_comment, and oauth_service.
I ran these commands to update my symfony2 entities:
php app/console doctrine:mapping:import testSiteBundle yml
php app/console doctrine:generate:entities test --path=src/
all tables are generated OK, but not the new one.
How can I generate the new table?
Doctrine2 does not act the same way as Doctrine1 for the many to many tables. If you want to have an entity, you have to create it and add one to many/many to one associations by yourself.