UseHiLo EF Core 5 setting value to previous one - oracle

modelBuilder.HasSequence("SEQ_TEST").IncrementsBy(1);
entity.Property(e => e.TestId)
.HasPrecision(10)
.HasColumnName("TEST_ID")
.ValueGeneratedOnAdd()
.UseHiLo("SEQ_TEST", "SCHEMA_NAME");
I can add 10 rows but for 11th row, its again reverting back to previous TEST_ID resulting in PK violation.
Is there anything that I am missing here ?

This fixed my issue modelBuilder.HasSequence("SEQ_TEST","SCHEMA_NAME").IncrementsBy(1);

Related

PowerQuery Expression.Error: A cyclic reference was encountered during evaluation

Can't find the error in formula - the value is calculated throughout the column (when keeping errors - no rows shown), but I can't apply the changes though.((
if [Index] > 0 then
if articles_pivot{[Index]-1}[IN] <> null (when omitted the error remains) and [IN]=null then
articles_pivot{[Index]-1}[IN]
else null
else null
Thank you for advice!
If I an reading it right, all you really need to do is right click IN column and do fill ... down...
Otherwise, see if this works
= try if articles_pivot{[Index]-1}[IN] <> null and articles_pivot{[Index]}[IN] = null then articles_pivot{[Index]-1}[IN] else null otherwise null
decided to make it another way - in the origin table I've added Index column starting 0 and in the pivot table (made by pivoting the origin one) I've added index column starting 1, then merged them..)

dhtmlxgrid addRow() unusual behavior on checkbox

I am trying to add rows to a grid using dhtmlx in java, following is the code.
var combinedColumn = "displayText";
displayOptionsGrid.addRow(selectedID, [ displayOptionsGrid.getRowsNum() == 0 ? 1 : 0, combinedColumn]);
What the function is supposed to do is that if the number of rows is zero it adds the first row as checked and then the rest as unchecked. The error which I am facing is, I delete the rows one by one and try to re-add the rows in the same session with some other row at first than the row I added previously, but can't. I can only add the row which I added first previously as the first row.
When I use grid.clearAll() it works fine. Can someone tell me the exact thing we do in clearAll() which we don't in deleteSelectedRows() in dhtmlxgrid. Thanks.
Please, check your selectedID attribute.
Note that each row should have a unique id, so adding a row with the id existing in your grid will break the grid.

Laravel update column for all users based on old value

I have days column in my users table, I need to run a cron job command using Laravel to decrease 1 from the users days column.
I know that I can use it to update all rows at once:
DB::table('Users')->update(['column' => 'value']);
But how I can set value to each member days - 1 ?
Use
DB::table('Users')->decrement('days', 1);
Or,
Since you want to decrement by 1, you can skip value part.
DB::table('Users')->decrement('days');
Find details here https://laravel.com/docs/5.3/queries#increment-and-decrement
You can update by: DB::table('Users')->update(['column' => DB::raw('value + 7')]);
Of course if you don't want to decrement or increment!

how can I group sum and count with sequel ORM and postgresl?

This is too tough for me guys. It's for Jeremy!
I have two tables (although I can also envision needing to join a third table) and I want to sum one field and count rows, in the same, table while joining with another table and return the result in json format.
First of all, the data type field that needs to be summed, is numeric(10,2) and the data is inserted as params['amount'].to_f.
The tables are expense_projects which has the name of the project and the company id and expense_items which has the company_id, item and amount (to mention just the critical columns) - the "company_id" columns are disambiguated.
So, the following code:
expense_items = DB[:expense_projects].left_join(:expense_items, :expense_project_id => :project_id).where(:project_company_id => company_id).to_a.to_json
works fine but when I add
expense_total = expense_items.sum(:amount).to_f.to_json
I get an error message which says
TypeError - no implicit conversion of Symbol into Integer:
so, the first question is why and how can this be fixed?
Then I want to join the two tables and get all the project names form the left (first table) and sum amount and count items in the second table. I have tried
DB[:expense_projects].left_join(:expense_items, :expense_items_company_id => expense_projects_company_id).count(:item).sum(:amount).to_json
and variations of this, all of which fails.
I would like a result which gets all the project names (even if there are no expense entries and returns something like:
project item_count item_amount
pr 1 7 34.87
pr 2 0 0
and so on. How can this be achieved with one query returning the result in json format?
Many thanks, guys.
Figured it out, I hope this helps somebody else:
DB[:expense_projects___p].where(:project_company_id=>user_company_id).
left_join(:expense_items___i, :expense_project_id=>:project_id).
select_group(:p__project_name).
select_more{count(:i__item_id)}.
select_more{sum(:i__amount)}.to_a.to_json

Propel: How the "Affected Rows" Returned from doUpdate is defined

In propel there is this doUpdate function, that will return the numbers of affected rows by this query.
The question is, if there is no need to update the row ( because the set value is already the same as the field value), will those rows counted as the affected row?
Take for example, I have the following table:
ID | Name | Books
1 | S1oon | Me
2 | S1oon | Me
Let's assume that I write a ORM function of the equivalent of the following query:
update `new table` set
Books='Me'
where Name='S1oon';
What will the doUpdate result return? Will it return 0 ( because all the Books column are already Me, hence there is no need to update), or will it be 2 ( because there are 2 rows that fulfill the where condition) ?
Under the hood, Propel is using PDO's PDOStatement::rowCount() method to return the number of affected rows. So, the short answer is that you'll get "2" as you expect here, but the longer answer is that it may depend slightly on how PDO implements that function for your specific database. (I think if you did not get 2, it should be a bug for PDO, however.)
See the description of rowCount() in the PHP manual for more info.
One other thing to bear in mind is that when Propel calls methods (like save() or delete()) which are expected to return number-of-rows-modified and which may result in more than one row being modified (e.g. if you add a Book and its Author and then cause both to be INSERTed by calling book->save()), you will get the total number of rows modified.
It will return 2.

Resources