anyone present here for a question?
# fw1
s
anyone present here for a question?
👋 1
a
yes - if I know the answer is something else though
s
Here goes nothing! Do you know if it's possible to use `fromFactory()`with DI/1 with a dynamic argument at calling time? e.g.
beanFactory.getBean( "factoriedObject" ).withArguments( ... )
instead of registering it with static arguments in a load listener?
a
I wouldn't think so no. But you could just create your own factory couldn't you? What's the usecase?
s
I solved it as such. I registered a factory object as the bean and call the
create
function on that factory object in the beanFactory.
👍 1
@aliaspooryorik any experience with
qb
?
a
yes
s
I'm using the
upsert
method for updating / inserting some values - using MSSQL btw - but it seems to complain about an auto-increment field
I have a statement as such:
Copy code
values = [ { "id": 1, "name": "foo" }, { "id": 2, "name": "bar" } ];
qb.table( "lorem" ).upsert( values = values, target = "id" );
a
Is it a SQL error or qb error?
s
SQL error due to the fact of the query being built by QB, i presume...
a
Can you see the SQL in the error?
s
Copy code
MERGE [dbo].[table] AS [qb_target] USING (
  VALUES
    (
      (param 1),
      (param 2),
      (param 3),
      (param 4),
      (param 5)
    )
) AS [qb_src] (
  [a],
  [b],
  [c],
  [id],
  [d]
) ON [qb_target].[id] = [qb_src].[id]
WHEN MATCHED THEN
UPDATE
SET
  [a] = [qb_src].[a],
  [b] = [qb_src].[b],
  [c] = [qb_src].[c],
  [id] = [qb_src].[id],
  [d] = [qb_src].[d]
  WHEN NOT MATCHED BY TARGET THEN
INSERT
  (
    [a],
    [b],
    [c],
    [id],
    [d]
  )
VALUES
  (
    [a],
    [b],
    [c],
    [id],
    [d]
  );
It should omit the `id`column, but still use it as
target
parameter to define whether or not to insert / update the record
When I use the parameter
update
for the
upsert
clause, the
id
column disappears from the UPDATE statement, but it remains in the INSERT statement
a
So adding the
update
parameter with the keys as an array solves the issue?
s
Partially.
It should also remove the 'id' parameter from the INSERT statement in the MERGE statement, but it does not...
a
why should it?
Not all tables will have an auto-increment field at the PK.
s
In my case, they do. So it all comes down to the question; is there a configuration option for solving this issue?
s
Yeah, was afraid i was going to need to use the updateOrInsert
upsert was convenient for bulk operations
updateOrInsert can't handle bulk record processing if i'm not mistaken.
a
yeah
There's an
source
option which accepts a closure - never used it though
s
I'll just use the updateOrInsert in a loop for now 🙂
Thanks for letting me pick your brain 😉
a
I've had a look through the code and don't think it'll handle your auto-inc primary key. You can ask in #box-products though