I was reading through the JHipster "Creating an entity", and did not see any Field Type related to JSONB. Does JHipster have any examples of jsonb field types?
Related
I am trying to fetch group by data in Django. I`m using postgres database
How I Can write Django query like this SQL query:-
SELECT id FROM table_name WHERE name=%s GROUP BY name"
I am trying with Model.objects.filter().values('id').annotate(count=Count('name')).order_by('name') but not get unique name`s id in QuerySet
and also try
Product.objects.filter(id__in=RawSQL(f"SELECT id FROM product_product WHERE name=%s GROUP BY name", (key,)))
but got error
"column \"product_product.id\" must appear in the GROUP BY clause or be used in an aggregate function\nLINE 1: ..._product\" WHERE \"product_product\".\"id\" IN (SELECT id FROM pr...
model.objects.filter(user=id).values('name').annotate(dcount=Count('name')).order_by()
You need to specify a filter value when u want to filter data from the model.
The value field takes in the value you want not the id
Then you annotate it.
For more information you can read the django documentation: here
I'm trying to create a schema and add tables to it via node using node-postgres (pg). The basic order of events is as follows:
1. Create schema
2. Create table in schema
3. Create columns in table in schema
I can verify that the schema and the table are being created without issues, but I get a relation does not exist error when trying to add the first column to the table. The query string for creating the column looks like this:
"ALTER TABLE " +
schemaName +
".process ADD COLUMN process_id bigint NOT NULL DEFAULT nextval('" +
schemaName +
".process_process_id_seq'::regclass)";
I've confirmed in the console log that the schema name variable matches what is was used to successfully create the table. Any ideas on why the error is being thrown here?
The sequence needs to be created beforehand.
But you could also use the bigserial type which is a shortcut for a bigint column with a sequence and a respective DEFAULT created automatically. Something along the lines of:
"ALTER TABLE " +
schemaName +
".process ADD COLUMN process_id bigserial";
Maybe you fell over that. Later, when the table/column was created you cannot see the ...serial anymore but the actual type and the DEFAULT.
More on ...serial types can be found in the documentation.
I'm trying to figure out when to use PXDBScalar. Do you guys know the difference between PXSelector and PXDBScalar and when to use which one?
In short PXDBScalar is normally used for unbound DAC fields (not stored in the table). For example if you wanted to have a Vendor name handy within a DAC fetch you could configure a DAC field with the vendor name without having to actually store it in the table. Also this works well with GI's.
PXSelector is an attribute for a DAC field that will allow the GUI to perform a look up of 'possible values' as related to the field.
The below explanations are from help.acumatica.com.
PXDBScalar:
Defines the SQL sub request that will be used to retrieve the value for the DAC field.
You should place the attribute on the field that is not bound to any particular database column.
The attribute will translate the provided BQL Search command into the SQL sub request and insert it into the select statement that retrieves data records of this DAC. In the BQL command, you can reference any bound field of any DAC.
Note that you should also annotate the field with an attribute that indicates an unbound field of a particular data type. Otherwise, the field may be displayed incorrectly in the user interface.
You should not use fields marked with the PXDBScalar attribute in BQL parameters (Current, Optional, and Required).
PXSelector:
Configures the lookup control for a DAC field that references a data record from a particular table by holding its key field.
I'm working with PencilBlue, and I'm having trouble with the custom objects Id's. The "name" field is used as an Id, but I would like it to be just a regular field and have an "id" field as identifier.
How could I achieve this?
PencilBlue cofounder here. Each custom object will have a unique id field supplied from the MongoDB database. You can also create another form field for a non-unique name and use the name field for UID.
I am trying to create a custom Audit summary report based on a date range that needs to be emailed nightly. I've got most of it working, but need some help with getting the primary name/field/attribute for a referenced entity. I noticed in the Audit view for a referenced entity, the data is stored like 'systemuser;'. What I would like to do is grab the Primary Field (Primary Name, Primary Attribute, whatever it's called) to display on the report. Does anyone know how to find the Primary Name attribute for an entity using the MetadataSchema views in the CRM SQL database? I have found the Primary Key field by looking at the MetadataSchema.Attribute.IsPKAttribute field, but I don't see anything for the Primary Name field.
Also, I am grabbing the current values from the entities if there are no following audit entries. For the lookup fields (like owner or customer) how can I tell from the Metadata what field stores the ObjectTypeCode? For example, if I was looking up the customer on a sales order, I know I can look at CustomerIdType field to find the ObjectTypeCode, but I need to find that the field is called CustomerIdType from the metadata.
If anyone has any good references on the Metadata from the SQL side of CRM, I would greatly appreciate it.
SQL query to get primary fields for all entities
SELECT e.Name as 'entity', a.Name as 'primary field'
FROM [dbo].EntityView e
left join [dbo].AttributeView a on e.EntityId = a.EntityId
where (a.DisplayMask & 256) > 0 --256 is for primary field
order by e.name
There are two cases to get object type code of lookup
append Type to field name (i.e. CustomerIdType)
if above is not available, get it from AttributeMetadata
SELECT ReferencedEntityObjectTypeCode
FROM [Discworld_MSCRM].[dbo].[AttributeView]
where name = '<field name>' and entityid = '<entity id>'
I'm not sure what exact rules are for Type fields to exist