Appreciate any help that you can provide.
I'm trying to create a 'Runway' model then attach 'Model' IDs for a many-to-many relationship within a transaction.
The model is still created when an error is thrown during attach (i.e. the transaction is not rolled back). What am I doing wrong?
export function create(object) {
var data = _.pick(object, ['name', 'userId']);
return Bookshelf.transaction((t) => {
return Runway.forge(data)
.save(null, {transaction: t})
.then((runway) => {
return runway.models().attach(object.models, {transaction: t});
})
})
.catch(err => {
winston.error('Error creating runway', {err: err});
throw err;
});
}
Logs:
Mon, 10 Oct 2016 06:07:59 GMT knex:tx trx1: Starting top level transaction
{ method: 'insert',
options: {},
timeout: false,
cancelOnTimeout: false,
bindings:
[ 2016-10-10T06:07:59.769Z,
'bf649bbf-c37f-426a-98e3-707e49eb17c6',
'my custom runway',
2016-10-10T06:07:59.769Z,
'66da84f6-45f4-4217-a995-dfb92cb246f1' ],
__knexQueryUid: 'c54606e4-7e4c-4a04-b66b-2f747df1ad6d',
sql: 'insert into `runways` (`created_at`, `id`, `name`, `updated_at`, `userId`) values (?, ?, ?, ?, ?)' }
{ method: 'insert',
options: {},
timeout: false,
cancelOnTimeout: false,
bindings:
[ 'f0a3bc21-2315-4b83-9cac-bab1fc019f1555',
'bf649bbf-c37f-426a-98e3-707e49eb17c6' ],
__knexQueryUid: '6125efce-3ef4-4327-a4ed-445634a26057',
sql: 'insert into `runways_models` (`modelId`, `runwayId`) values (?, ?)' }
Mon, 10 Oct 2016 06:07:59 GMT knex:tx trx1: releasing connection
2016-10-10T06:07:59.815Z ERROR [winston-fh] Error creating runway [METADATA]: {"err":{"message":"insert into `runways_models` (`modelId`, `runwayId`) values ('f0a3bc21-2315-4b83-9cac-bab1fc019f1555', 'bf649bbf-c37f-426a-98e3-707e49eb17c6') - ER_NO_REFERENCED_ROW_2: Cannot add or update a child row: a foreign key constraint fails (`figurehappy`.`runways_models`, CONSTRAINT `runways_models_modelid_foreign` FOREIGN KEY (`modelId`) REFERENCES `users` (`id`))","stack":"Error: ER_NO_REFERENCED_ROW_2: Cannot add or update a child row: a foreign key constraint fails (`figurehappy`.`runways_models`, CONSTRAINT `runways_models_modelid_foreign` FOREIGN KEY (`modelId`) REFERENCES `users` (`id`))\n at Query.Sequence._packetToError (/Users/Nim/Workspace/figurehappy/node_modules/mysql/lib/protocol/sequences/Sequence.js:51:14)\n at Query.ErrorPacket (/Users/Nim/Workspace/figurehappy/node_modules/mysql/lib/protocol/sequences/Query.js:83:18)\n at Protocol._parsePacket (/Users/Nim/Workspace/figurehappy/node_modules/mysql/lib/protocol/Protocol.js:280:23)\n at Parser.write (/Users/Nim/Workspace/figurehappy/node_modules/mysql/lib/protocol/Parser.js:74:12)\n at Protocol.write (/Users/Nim/Workspace/figurehappy/node_modules/mysql/lib/protocol/Protocol.js:39:16)\n at Socket.<anonymous> (/Users/Nim/Workspace/figurehappy/node_modules/mysql/lib/Connection.js:109:28)\n at emitOne (events.js:96:13)\n at Socket.emit (events.js:188:7)\n at readableAddChunk (_stream_readable.js:177:18)\n at Socket.Readable.push (_stream_readable.js:135:10)\n at TCP.onread (net.js:542:20)\n --------------------\n at Protocol._enqueue (/Users/Nim/Workspace/figurehappy/node_modules/mysql/lib/protocol/Protocol.js:141:48)\n at Connection.query (/Users/Nim/Workspace/figurehappy/node_modules/mysql/lib/Connection.js:214:25)\n at /Users/Nim/Workspace/figurehappy/node_modules/knex/lib/dialects/mysql/index.js:124:18\n at Promise._execute (/Users/Nim/Workspace/figurehappy/node_modules/bluebird/js/release/debuggability.js:284:9)\n at Promise._resolveFromExecutor (/Users/Nim/Workspace/figurehappy/node_modules/bluebird/js/release/promise.js:480:18)\n at new Promise (/Users/Nim/Workspace/figurehappy/node_modules/bluebird/js/release/promise.js:77:14)\n at Client._query (/Users/Nim/Workspace/figurehappy/node_modules/knex/lib/dialects/mysql/index.js:118:12)\n at Client.query (/Users/Nim/Workspace/figurehappy/node_modules/knex/lib/client.js:187:24)\n at Runner.<anonymous> (/Users/Nim/Workspace/figurehappy/node_modules/knex/lib/runner.js:129:36)\n at Runner.tryCatcher (/Users/Nim/Workspace/figurehappy/node_modules/bluebird/js/release/util.js:16:23)\n at Runner.query (/Users/Nim/Workspace/figurehappy/node_modules/bluebird/js/release/method.js:15:34)\n at /Users/Nim/Workspace/figurehappy/node_modules/knex/lib/runner.js:55:21\n at tryCatcher (/Users/Nim/Workspace/figurehappy/node_modules/bluebird/js/release/util.js:16:23)\n at /Users/Nim/Workspace/figurehappy/node_modules/bluebird/js/release/using.js:185:26\n at tryCatcher (/Users/Nim/Workspace/figurehappy/node_modules/bluebird/js/release/util.js:16:23)\n at Promise._settlePromiseFromHandler (/Users/Nim/Workspace/figurehappy/node_modules/bluebird/js/release/promise.js:509:31)\n at Promise._settlePromise (/Users/Nim/Workspace/figurehappy/node_modules/bluebird/js/release/promise.js:566:18)\n at Promise._settlePromise0 (/Users/Nim/Workspace/figurehappy/node_modules/bluebird/js/release/promise.js:611:10)\n at Promise._settlePromises (/Users/Nim/Workspace/figurehappy/node_modules/bluebird/js/release/promise.js:690:18)\n at Promise._fulfill (/Users/Nim/Workspace/figurehappy/node_modules/bluebird/js/release/promise.js:635:18)\n at PromiseArray._resolve (/Users/Nim/Workspace/figurehappy/node_modules/bluebird/js/release/promise_array.js:125:19)\n at PromiseArray._promiseFulfilled (/Users/Nim/Workspace/figurehappy/node_modules/bluebird/js/release/promise_array.js:143:14)\n at Promise._settlePromise (/Users/Nim/Workspace/figurehappy/node_modules/bluebird/js/release/promise.js:571:26)\n at Promise._settlePromise0 (/Users/Nim/Workspace/figurehappy/node_modules/bluebird/js/release/promise.js:611:10)\n at Promise._settlePromises (/Users/Nim/Workspace/figurehappy/node_modules/bluebird/js/release/promise.js:690:18)\n at Async._drainQueue (/Users/Nim/Workspace/figurehappy/node_modules/bluebird/js/release/async.js:138:16)\n at Async._drainQueues (/Users/Nim/Workspace/figurehappy/node_modules/bluebird/js/release/async.js:148:10)\n at Immediate.Async.drainQueues (/Users/Nim/Workspace/figurehappy/node_modules/bluebird/js/release/async.js:17:14)\n at runCallback (timers.js:570:20)\n at tryOnImmediate (timers.js:550:5)\n at processImmediate [as _immediateCallback] (timers.js:529:5)","code":"ER_NO_REFERENCED_ROW_2","errno":1452,"sqlState":"23000","index":0}}
insert into `runways_models` (`modelId`, `runwayId`) values ('f0a3bc21-2315-4b83-9cac-bab1fc019f1555', 'bf649bbf-c37f-426a-98e3-707e49eb17c6') - ER_NO_REFERENCED_ROW_2: Cannot add or update a child row: a foreign key constraint fails (`figurehappy`.`runways_models`, CONSTRAINT `runways_models_modelid_foreign` FOREIGN KEY (`modelId`) REFERENCES `users` (`id`))
Error: ER_NO_REFERENCED_ROW_2: Cannot add or update a child row: a foreign key constraint fails (`figurehappy`.`runways_models`, CONSTRAINT `runways_models_modelid_foreign` FOREIGN KEY (`modelId`) REFERENCES `users` (`id`))
Sorry... this was a User error.
I should have written {transacting: t} instead of {transaction: t}.
Related
I'm quite new to rails and have been studying this database migration.
I have created three tables(models) for my practices namely: **clinicstaffs, beds, **and medicalrecords,
I have edited the clinicstaffs primary key to schoolID,
class CreateClinicstaffs < ActiveRecord::Migration[7.0]
def change
create_table :clinicstaffs, id: false do |t|
t.integer :schoolID, null: false, primary_key: true
t.string :type
t.string :firstname
t.string :middlename
t.string :lastname
t.timestamps
end
end
end
and wanted to assign schoolID as a foreign key on the beds table. I used the rails g migration Add_clinicstaffs_To_beds clinicstaffs:references and produced :
class AddClinicstaffsToBeds < ActiveRecord::Migration[7.0]
def change
add_reference :beds, :clinicstaffs, null: false, foreign_key: true
end
end
but after running rake db:migrate it gives me : foreign key mismatch error.
PS C:\Users\ArmbelBernal\Desktop\MedicalRecords> rake db:migrate
== 20221202165814 AddClinicstaffsToBeds: migrating ============================
-- add_reference(:beds, :clinicstaffs, {:null=>false, :foreign_key=>true})
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
SQLite3::SQLException: foreign key mismatch - "beds" referencing "clinicstaffs"
C:/Users/ArmbelBernal/Desktop/MedicalRecords/db/migrate/20221202165814_add_clinicstaffs_to_beds.rb:3:in `change'
Caused by:
ActiveRecord::StatementInvalid: SQLite3::SQLException: foreign key mismatch - "beds" referencing "clinicstaffs"
C:/Users/ArmbelBernal/Desktop/MedicalRecords/db/migrate/20221202165814_add_clinicstaffs_to_beds.rb:3:in `change'
Caused by:
SQLite3::SQLException: foreign key mismatch - "beds" referencing "clinicstaffs"
C:/Users/ArmbelBernal/Desktop/MedicalRecords/db/migrate/20221202165814_add_clinicstaffs_to_beds.rb:3:in `change'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
is there anyway to fix this? thanks!
=========================================================
Tried to generate a new scaffold secondbeds status:string assessment:string with a clinicstaffs:references
produces:
class CreateSecondbeds < ActiveRecord::Migration[7.0]
def change
create_table :secondbeds do |t|
t.string :status
t.string :assessment
t.references :clinicstaff, null: false, foreign_key: true
t.timestamps
end
and edited this file to:
class CreateSecondbeds < ActiveRecord::Migration[7.0]
def change
create_table :secondbeds do |t|
t.string :status
t.string :assessment
t.references :clinicstaff_schoolID, references: :clinicstaffs, null: false
t.timestamps
end
rename_column :secondbeds, :clinicstaff_schoolID_id, :clinicstaff_schoolID
add_foreign_key :secondbeds, :clinicstaffs, column: 'clinicstaff_schoolID', primary_key: 'schoolID'
end
end
this does not give me error in running rake db:migrate << how can I implement this in a model I have already created? thanks
I installed the DB with updates and I got this error:
Opening DatabasePool 'wotlk_world'. Asynchronous connections: 1, synchronous connections: 1. MySQL client library: 5.6.42 MySQL server ver: 5.6.42 MySQL client library: 5.6.42 MySQL server ver: 5.6.42 [ERROR]: In mysql_stmt_prepare() id: 4, sql: "SELECT entryorguid, source_type, id, link, event_type, event_phase_mask, event_chance, event_flags, event_param1, event_param2, event_param3, event_param4, event_param5, action_type, action_param1, action_param2, action_param3, action_param4, action_param5, action_param6, target_type, target_param1, target_param2, target_param3, target_param4, target_x, target_y, target_z, target_o FROM smart_scripts ORDER BY entryorguid, source_type, id, link" [ERROR]: Unknown column 'event_param5' in 'field list' [ERROR]: In mysql_stmt_prepare() id: 54, sql: "SELECT difficulty_entry_1, difficulty_entry_2, difficulty_entry_3, KillCredit1, KillCredit2, modelid1, modelid2, modelid3, modelid4, name, subname, IconName, gossip_menu_id, minlevel, maxlevel, exp, faction, npcflag, speed_walk, speed_run, scale, rank, mindmg, maxdmg, dmgschool, attackpower, DamageModifier, BaseAttackTime, RangeAttackTime, unit_class, unit_flags, unit_flags2, dynamicflags, family, trainer_type, trainer_spell, trainer_class, trainer_race, minrangedmg, maxrangedmg, rangedattackpower, type, type_flags, lootid, pickpocketloot, skinloot, resistance1, resistance2, resistance3, resistance4, resistance5, resistance6, spell1, spell2, spell3, spell4, spell5, spell6, spell7, spell8, PetSpellDataId, VehicleId, mingold, maxgold, AIName, MovementType, InhabitType, HoverHeight, HealthModifier, ManaModifier, ArmorModifier, RacialLeader, movementId, RegenHealth, mechanic_immune_mask, flags_extra, ScriptName FROM creature_template WHERE entry = ?" [ERROR]: Unknown column 'DamageModifier' in 'field list' DatabasePool wotlk_world NOT opened. There were errors opening the MySQL connections. Check your SQLDriverLogFile for specific errors. Cannot connect to world database
127.0.0.1;3306;root;ascent;wotlk_world
The problem is:
[ERROR]: Unknown column 'DamageModifier' in 'field list'
It looks like your world DB is not up to date. So you need to update it properly. To do that you can either use the DB assembler script (bin/acore-db-asm) or manually importing the missing sql files from data/sql/updates/db_world.
To make sure your DB is up to date, check the name of the last column of the table version_db_world of your world database. It should match with the most recent sql file name of the direcotry data/sql/updates/db_world.
I recommend reading:
How to make sure that the DB is up to date
I'm using PostgreSQL 9.5 and flyway 5.0.7
Everything worked fine for the previous 6 migrations but now it blocks for the latest
I have the following error :
22:27:45.230 [INFO ] o.f.c.i.u.l.slf4j.Slf4jLog - Flyway Community Edition 5.0.7 by Boxfuse
22:27:45.408 [INFO ] o.f.c.i.u.l.slf4j.Slf4jLog - Database: jdbc:postgresql://localhost:32767/my_db (PostgreSQL 9.5)
22:27:45.566 [INFO ] o.f.c.i.u.l.slf4j.Slf4jLog - Successfully validated 7 migrations (execution time 00:00.061s)
22:27:45.658 [INFO ] o.f.c.i.u.l.slf4j.Slf4jLog - Current version of schema "public": 6
22:27:45.733 [INFO ] o.f.c.i.u.l.slf4j.Slf4jLog - Migrating schema "public" to version 7 - update
Exception in thread "main" org.flywaydb.core.internal.exception.FlywaySqlException:
Unable to insert row for version '7' in Schema History table "public"."flyway_schema_history"
---------------------------------------------------------------------------------------------
SQL State : 23502
Error Code : 0
Message : ERROR: null value in column "version_rank" violates not-null constraint
Détail : Failing row contains (null, 7, 7, update, SQL, V7__update.sql, -1303600795, postgres, 2018-02-25 22:28:00.536556, 158, t).
at org.flywaydb.core.internal.schemahistory.JdbcTableSchemaHistory.doAddAppliedMigration(JdbcTableSchemaHistory.java:171)
at org.flywaydb.core.internal.schemahistory.SchemaHistory.addAppliedMigration(SchemaHistory.java:146)
at org.flywaydb.core.internal.command.DbMigrate.doMigrateGroup(DbMigrate.java:378)
at org.flywaydb.core.internal.command.DbMigrate.access$400(DbMigrate.java:52)
at org.flywaydb.core.internal.command.DbMigrate$5.call(DbMigrate.java:297)
at org.flywaydb.core.internal.util.jdbc.TransactionTemplate.execute(TransactionTemplate.java:75)
at org.flywaydb.core.internal.command.DbMigrate.applyMigrations(DbMigrate.java:294)
at org.flywaydb.core.internal.command.DbMigrate.migrateGroup(DbMigrate.java:259)
at org.flywaydb.core.internal.command.DbMigrate.access$300(DbMigrate.java:52)
at org.flywaydb.core.internal.command.DbMigrate$4.call(DbMigrate.java:179)
at org.flywaydb.core.internal.command.DbMigrate$4.call(DbMigrate.java:176)
at org.flywaydb.core.internal.database.postgresql.PostgreSQLAdvisoryLockTemplate.execute(PostgreSQLAdvisoryLockTemplate.java:71)
at org.flywaydb.core.internal.database.postgresql.PostgreSQLConnection.lock(PostgreSQLConnection.java:110)
at org.flywaydb.core.internal.schemahistory.JdbcTableSchemaHistory.lock(JdbcTableSchemaHistory.java:148)
at org.flywaydb.core.internal.command.DbMigrate.migrateAll(DbMigrate.java:176)
at org.flywaydb.core.internal.command.DbMigrate.migrate(DbMigrate.java:145)
at org.flywaydb.core.Flyway$1.execute(Flyway.java:1206)
at org.flywaydb.core.Flyway$1.execute(Flyway.java:1168)
at org.flywaydb.core.Flyway.execute(Flyway.java:1655)
at org.flywaydb.core.Flyway.migrate(Flyway.java:1168)
at com.test.MyApplication.main(MainApplication.java:47)
Caused by: org.postgresql.util.PSQLException: ERROR: null value in column "version_rank" violates not-null constraint
Détail : Failing row contains (null, 7, 7, update, SQL, V7__update.sql, -1303600795, postgres, 2018-02-25 22:28:00.536556, 158, t).
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2422)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2167)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:306)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)
at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:155)
at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:132)
at org.flywaydb.core.internal.util.jdbc.JdbcTemplate.update(JdbcTemplate.java:334)
at org.flywaydb.core.internal.schemahistory.JdbcTableSchemaHistory.doAddAppliedMigration(JdbcTableSchemaHistory.java:165)
... 20 more
Any idea why this column "version_rank" is not generated or not initialized ?
Thanks in advance for your help
You upgraded from Flyway 3.x to 5.x, skipping 4.x. This is not possible as written in the release notes: https://flywaydb.org/documentation/releaseNotes#5.0.0
Upgrade to 4.2.0 first before upgrading to 5.x and everything will work as expected.
Also please take a minute to check the release notes next time you upgrade a major version.
Here's the commit with the metadata table changes if you need to apply the changes manually. I've linked to the version for postgres - search for the version of upgradeMetaDataTable.sql in the folder matching the required dialect.
Fortunately you can apply the changes as a standard flyway migration, as the metadata tables are not used until the end of each script.
E.G. create a migration V999.00__FlywayFix.sql to correct a flyway version table called flyway_table as follows:
DROP INDEX "flyway_table_vr_idx";
DROP INDEX "flyway_table_ir_idx";
ALTER TABLE "flyway_table" DROP COLUMN "version_rank";
ALTER TABLE "flyway_table" DROP CONSTRAINT "flyway_table_pk";
ALTER TABLE "flyway_table" ALTER COLUMN "version" DROP NOT NULL;
ALTER TABLE "flyway_table" ADD CONSTRAINT "flyway_table_pk" PRIMARY KEY ("installed_rank");
UPDATE "flyway_table" SET "type"='BASELINE' WHERE "type"='INIT';
it's worked for me for Postgres
CREATE TABLE flyway_schema_history (
installed_rank INTEGER NOT NULL,
version varchar(50) DEFAULT NULL,
description varchar(200) NOT NULL,
type varchar(20) NOT NULL,
script varchar(1000) NOT NULL,
checksum INTEGER DEFAULT NULL,
installed_by varchar(100) NOT NULL,
installed_on timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
execution_time INTEGER NOT NULL,
success BOOLEAN NOT NULL,
PRIMARY KEY (installed_rank)
);
INSERT INTO flyway_schema_history (installed_rank, version, description, type, script, checksum, installed_by, installed_on, execution_time, success)
SELECT installed_rank, version, description, type, script, checksum, installed_by, installed_on, execution_time, success
FROM schema_version;
ALTER TABLE schema_version RENAME TO bak_schema_version;
I created a fork of ecto repository to extend Ecto.Changeset module with the ability to add warnings to the changeset. I wanted to have an add_warnings/4 function which adds a warning to the changeset as a simple list of warnings with this structure warnings: [{atom, {String.t, Keyword.t}}], similar to errors. The difference between the behavior of warnings and errors is that when an error occurs the data are not persisted, but when a warning occurs the data are persisted.
Ecto.Changeset struct extended with keys warnings and warningless?:
defstruct valid?: false, warningless?: false, data: nil, params: nil, changes: %{}, repo: nil,
errors: [], warnings: [], validations: [], required: [], prepare: [],
constraints: [], filters: %{}, action: nil, types: nil,
empty_values: #empty_values
Ecto functions for casting, changing, processing params, etc. adjusted. Function add_warnings/4 added:
#spec add_warning(t, atom, String.t, Keyword.t) :: t
def add_warning(%{warnings: warnings} = changeset, key, message, keys \\ []) when is_binary(message) do
%{changeset | warnings: [{key, {message, keys}}|warnings], warningless?: false}
end
The result is that I receive changeset with expected keys:
#Ecto.Changeset<action: nil, changes: %{}, data: #Company.Booking<>, errors: [],
valid?: true, warnings: [], warningless?: true>
When I make a change with error and warning I receive:
#Ecto.Changeset<action: nil,
changes: %{pickup_address: #Ecto.Changeset<action: :update,
changes: %{street_name: nil}, data: #Company.Address<>,
errors: [street_name: {"can't be blank", [validation: :required]}],
valid?: false,
warnings: [phone_number: {"This phone number is not common in Netherlands",
[]}], warningless?: false>}, data: #Company.Booking<>, errors: [],
valid?: false, warnings: [], warningless?: true>
So, everything is as expected, as far as warnings are concerned. Then, when I make a change with a warning but without an error, I receive:
#Ecto.Changeset<action: nil,
changes: %{pickup_address: #Ecto.Changeset<action: :update,
changes: %{street_name: "sss"}, data: #Company.Address<>, errors: [],
valid?: true,
warnings: [phone_number: {"This phone number is not common in Netherlands",
[]}], warningless?: false>}, data: #Company.Booking<>, errors: [],
valid?: true, warnings: [], warningless?: true>
Everything is as expected. When I don't make any changes to the form I still should receive a warning for phone number, but I receive:
#Ecto.Changeset<action: nil, changes: %{}, data: #Company.Booking<>, errors: [],
valid?: true, warnings: [], warningless?: true>
I got a changeset without any warnings as there is no changes key in changeset because the data didn't change.
The question is as follows, how to implement warnings functionality to always have warnings in the changeset, even if no change was made?
You should consider to prefill the warnings at the very beginning of the each changeset function you would create - since you can't use plug there you can come up to write a macro that will handle this logic for you, __using__ is advised, so it would be quite easy to distinguish your logic from Ecto's default logic.
Your validation shouldn't add warnings to warnings list, but you have to implement it another way around - if the field is fine, you would remove already existing warnings from this list. That way you would be sure that your changeset is fine when it's warningless, because it removed all the warnings from this list and it would works perfectly for empty changes in changeset.
I am trying to query a table called "user_path_summary" for a value that is equal to my hashkey, "username" and also equal to my global secondary index hashkey, "full_path". I am hoping to get back one attribute, "articles_read". The parameters that I am using are:
var params = {
"TableName": "user_path_summary",
"IndexName": "full_path_index",
"KeyConditionExpression": "full_path = :v_full_path AND username = v:username",
"ExpressionAttributeValues": {
":v_username": {"S" : username},
":v_full_path": {"S": full_path}
},
"ProjectionExpression": "articles_read",
"ScanIndexForward": false
};
I get the following error.
{ [MultipleValidationErrors: There were 2 validation errors:
* MissingRequiredParameter: Missing required key 'KeyConditions' in params
* UnexpectedParameter: Unexpected key 'KeyConditionExpression' found in params]
message: 'There were 2 validation errors:\n* MissingRequiredParameter: Missing required key \'KeyConditions\' in params\n* UnexpectedParameter: Unexpected key \'KeyConditionExpression\' found in params',
code: 'MultipleValidationErrors',
errors:
[ { [MissingRequiredParameter: Missing required key 'KeyConditions' in params]
message: 'Missing required key \'KeyConditions\' in params',
code: 'MissingRequiredParameter',
time: Sat Aug 01 2015 14:54:52 GMT-0400 (EDT) },
{ [UnexpectedParameter: Unexpected key 'KeyConditionExpression' found in params]
message: 'Unexpected key \'KeyConditionExpression\' found in params',
code: 'UnexpectedParameter',
time: Sat Aug 01 2015 14:54:52 GMT-0400 (EDT) } ],
time: Sat Aug 01 2015 14:54:52 GMT-0400 (EDT) }
I am confused because the error pertains to the missing parameter "KeyConditions", which is identified as a legacy parameter in the query API Reference, and also to the unexpected parameter "KeyConditionExpression" which the api reference says to use instead of "KeyConditions".
Is there a setting somewhere that I am missing? Is my syntax messed up somewhere. Please let me know, I am clearly missing something.