Giter Club home page Giter Club logo

Comments (55)

baopham avatar baopham commented on August 16, 2024

that sounds more like you didn't setup things right :

http://stackoverflow.com/questions/25886403/dynamodb-the-provided-key-element-does-not-match-the-schema

Can you give me your model class?

from laravel-dynamodb.

nam-co avatar nam-co commented on August 16, 2024

Thanks for the response, Im on L5.4, here is my model:

namespace App;
use Illuminate\Database\Eloquent\Model;
class Messages extends \BaoPham\DynamoDb\DynamoDbModel
{
protected $table = 'Billing_messages';
}

from laravel-dynamodb.

baopham avatar baopham commented on August 16, 2024

and what is your primary key in your DynamoDB table?

from laravel-dynamodb.

nam-co avatar nam-co commented on August 16, 2024

Primary: id (String), sort: create_at (String)

from laravel-dynamodb.

baopham avatar baopham commented on August 16, 2024

can you give me the code that causes the error?

from laravel-dynamodb.

nam-co avatar nam-co commented on August 16, 2024

is a 2 part code, one gets where I get the error
$message3 = Messages::find(1);

The second saves, this one doesn't give an error but it doesn't save anything on the table AWS console
$message = new Messages;
$message->id = uniqid('', true);
$message->save();

from laravel-dynamodb.

baopham avatar baopham commented on August 16, 2024

So:

  1. $message3 = Messages::find(1); gives you error? are you passing in a string or a number? looks like your primary key should be string instead.

  2. Are you sure your table only needs the id? you should fill in all other columns especially, create_at

from laravel-dynamodb.

nam-co avatar nam-co commented on August 16, 2024

this is an example of the table:
{
"content": "TAMBIEN claro que si\n\npero con return?",
"create_at": "2017-01-21 00:24:11",
"files": [
"the-file.jpg"
],
"from": 1,
"id": "1",
"order_id": 1
}

from laravel-dynamodb.

baopham avatar baopham commented on August 16, 2024

Right, so make sure when you set your id, it is a string.

Have you tried my suggestion 2?

from laravel-dynamodb.

nam-co avatar nam-co commented on August 16, 2024

Your suggestion No. 2 works, created_at what necessary to save, what do you think about the $message3 = Messages::find(1); is still showing the error

from laravel-dynamodb.

baopham avatar baopham commented on August 16, 2024

Try $message3 = Messages::find('1')

You're passing in a number so it wouldn't parse correctly.

from laravel-dynamodb.

nam-co avatar nam-co commented on August 16, 2024

even with $message3 = Messages::find('1'); I get the same error

from laravel-dynamodb.

baopham avatar baopham commented on August 16, 2024

do you have another record that you can test? Something that is not a number.

from laravel-dynamodb.

nam-co avatar nam-co commented on August 16, 2024

ok, I tried

  1. $message3 = Messages::where('order_id', '1')->first(); I got null (no error)
  2. $message3 = Messages::where('order_id', 1)->first(); I got error "MassAssignmentException in Model.php line 225: content"

from laravel-dynamodb.

nam-co avatar nam-co commented on August 16, 2024

let me try with created_at witch is a string

I got null

from laravel-dynamodb.

baopham avatar baopham commented on August 16, 2024

No. I meant do you have another ID that is not exactly a number and use that to test find

from laravel-dynamodb.

nam-co avatar nam-co commented on August 16, 2024

but the id is a (String) and sort: create_at (String)
I tried with content = "TAMBIEN claro que si\n\npero con return?" and got null

from laravel-dynamodb.

baopham avatar baopham commented on August 16, 2024

Sorry but I don't understand what you meant. Can you be more clear in your response?

Find some ID (primary key) that is more like a UUID and not a numeric.

from laravel-dynamodb.

nam-co avatar nam-co commented on August 16, 2024

ok , I saw a typo, I put in the table create_at missing the D, so I tried
$message3 = Messages::where('create_at', '2017-01-21 00:24:11')->first();
and got the same MassAssignmentException in Model.php line 225:

Im just trying to use where with multiple fields

from laravel-dynamodb.

baopham avatar baopham commented on August 16, 2024

There are a few things and I have no idea what you are asking:

  1. $message3 = Messages::find(1) or $message3 = Messages::find('1') which I kept asking you to try a different ID.
  2. $message3 = Messages::where('create_at', '2017-01-21 00:24:11')->first(); which I think you already solved it by fixing the typo.

So I'm really confused about what you are asking.

from laravel-dynamodb.

nam-co avatar nam-co commented on August 16, 2024

is the same thing, I can't query any results, they all show null or "MassAssignmentException in Model.php line 225: content" error
Im able to save, but not get any records

sorry

from laravel-dynamodb.

baopham avatar baopham commented on August 16, 2024

Try to setup your fillable attributes in your model:

$fillable = ['create_at', 'order_id', ...]

from laravel-dynamodb.

nam-co avatar nam-co commented on August 16, 2024

I always thought fillable was just for saving, but it works :) , now this 2 work:
$message2 = Messages::where('create_at', '2017-01-21 00:24:11')->first();
$message3 = Messages::where('create_at', '567')->get();

but find by id still doesn't :
$message1 = Messages::find('58badb381838c5.44840949'); OR
$message1 = Messages::where('id', '1')->first();
they still produce the same error as my first message (DynamoDbException)

from laravel-dynamodb.

baopham avatar baopham commented on August 16, 2024

I always thought fillable was just for saving

Ah yeah, I'm using Model::fill to give you back the model object so that's why you're getting the mass assignment error. I should use a different method though.

Do you have a stack trace for me?

from laravel-dynamodb.

nam-co avatar nam-co commented on August 16, 2024

Sorry I don't understand what "stack trace" is, but the logs in laravel don't show any error, I tried with other fields and it works, maybe I shouldn't name the primary "id" but something like "my_id"

from laravel-dynamodb.

nam-co avatar nam-co commented on August 16, 2024

thanks

from laravel-dynamodb.

baopham avatar baopham commented on August 16, 2024

You are not using composite key, are you?

from laravel-dynamodb.

nam-co avatar nam-co commented on August 16, 2024

All my model file is what I send you (+ the fillable), I don't think Im using a composite key

from laravel-dynamodb.

nam-co avatar nam-co commented on August 16, 2024

ok, I change the primary to primary_id and it work better, anyway found an error with this (“) “primary_id" in the json, so that might been the error?

Anyway $message1 = Messages::where('primary_id', '1')->first(); now works
but $message0 = Messages::find('1') still doesn't, but I can manage with the first one

from laravel-dynamodb.

baopham avatar baopham commented on August 16, 2024

hmmm try to define your primary key in your model?

protected $primaryKey = ['primary_id'];

from laravel-dynamodb.

baopham avatar baopham commented on August 16, 2024

I have a feeling that your table doesn't have the correct primary key.

from laravel-dynamodb.

nam-co avatar nam-co commented on August 16, 2024

I get error: Illegal offset type in isset or empty

from laravel-dynamodb.

baopham avatar baopham commented on August 16, 2024

Stack trace please?

from laravel-dynamodb.

nam-co avatar nam-co commented on August 16, 2024

Thanks

from laravel-dynamodb.

baopham avatar baopham commented on August 16, 2024

DynamoDbQueryBuilder->find(1) <--- this is why I would like you to try a different ID value that is not a numeric. E.g. Message::find('abcdefg'). Additionally, can you give me your updated model class and confirm what is your primary key now? is it id or primary_id?

from laravel-dynamodb.

nam-co avatar nam-co commented on August 16, 2024

class Messages extends \BaoPham\DynamoDb\DynamoDbModel
{
protected $table = 'messages';
protected $fillable = ['create_at', 'order_id', 'content', 'files', 'primary_id', 'from'];
protected $primaryKey = ['primary_id'];

from laravel-dynamodb.

nam-co avatar nam-co commented on August 16, 2024

in controller
$message = Messages::find('1');

from laravel-dynamodb.

baopham avatar baopham commented on August 16, 2024

Thanks. Now can you try a different ID value please? Nothing numeric.

from laravel-dynamodb.

nam-co avatar nam-co commented on August 16, 2024

I tried $message = Messages::find('hello'); same error

baopham with the DB in digital ocean Im getting an execution time of 0.025 and with Dynamo on AWS Im getting a 0.19 is this normal? I thought Dynamo was faster or is just local vs aws servers

from laravel-dynamodb.

baopham avatar baopham commented on August 16, 2024

$message = Messages::find('hello'); same error

Ok, I will have to find sometime and reproduce this.

with the DB in digital ocean Im getting an execution time of 0.025 and with Dynamo on AWS Im getting a 0.19 is this normal?

Umm, I don't understand. Are you testing all locally?

I thought Dynamo was faster

Depends really on how you design your tables.

is just local vs aws servers

Requests made from local environment tend to be slower.

from laravel-dynamodb.

nam-co avatar nam-co commented on August 16, 2024

When I mean local I mean the same DB in the digital ocean server where the app is running

Im getting the execution time with
$message = Messages::where('primary_id', '1')->first();
$time = microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"];
echo "Process Time sql: {$time}";

and then in another link Im using the Digital Ocean db

from laravel-dynamodb.

baopham avatar baopham commented on August 16, 2024

I'm afraid that this question is out of scope of this library. There are a lot of factors to take into account and I don't know how your DB, server, etc. are setup.

from laravel-dynamodb.

nam-co avatar nam-co commented on August 16, 2024

true, well I would like to thanks you for your help B, appreciate it a lot

from laravel-dynamodb.

baopham avatar baopham commented on August 16, 2024

No problem. As for the Message::find(...) error, I will try to reproduce it on my end but probably won't be able to until next weekend.

from laravel-dynamodb.

baopham avatar baopham commented on August 16, 2024

Sorry, couldn't find the time to work on this... I'll leave this open for now

from laravel-dynamodb.

nam-co avatar nam-co commented on August 16, 2024

Hi baopham, hope your ok, I was wondering, did you ever find a fix for the error?

Error executing "GetItem" on "https://dynamodb.us-east-1.amazonaws.com"; AWS HTTP error: Client error: POST https://dynamodb.us-east-1.amazonaws.com resulted in a 400 Bad Request response:
{"__type":"com.amazon.coral.validate#ValidationException","message":"The provided key element does not match the schema" (truncated...)
ValidationException (client): The provided key element does not match the schema - {"__type":"com.amazon.coral.validate#ValidationException","message":"The provided key element does not match the schema"}
fit happens with both
$message = Messages::find('59822b2cda8650.74115649');
and
$message = Messages::where('id', $id);

Appreciate the help

from laravel-dynamodb.

nam-co avatar nam-co commented on August 16, 2024

Hi baopham, I found a way :), once a gain thanks for the great package

from laravel-dynamodb.

baopham avatar baopham commented on August 16, 2024

Great! Congrats! Closing issue.

from laravel-dynamodb.

 avatar commented on August 16, 2024

@nam-co Would you be able to share your solution? having the same issue

from laravel-dynamodb.

nam-co avatar nam-co commented on August 16, 2024

Hi @kriiv tone honest I don't remember, it was like a year a go, but to be honest at the end I choose to use a regular mysql instead of AWS

from laravel-dynamodb.

baopham avatar baopham commented on August 16, 2024

@kriiv feel free to create a new issue.

from laravel-dynamodb.

krupali-mbarc avatar krupali-mbarc commented on August 16, 2024

Hi baopham, hope your ok, I was wondering, did you ever find a fix for the error?

Error executing "GetItem" on "https://dynamodb.us-east-1.amazonaws.com"; AWS HTTP error: Client error: POST https://dynamodb.us-east-1.amazonaws.com resulted in a 400 Bad Request response:
{"__type":"com.amazon.coral.validate#ValidationException","message":"The provided key element does not match the schema" (truncated...)
ValidationException (client): The provided key element does not match the schema - {"__type":"com.amazon.coral.validate#ValidationException","message":"The provided key element does not match the schema"}
fit happens with both
$message = Messages::find('59822b2cda8650.74115649');
and
$message = Messages::where('id', $id);

Appreciate the help

Hi @nam-co and @baopham , i'm stiil facing this above error issue for find and where query. Can you please help me out to resolve issue or error?

from laravel-dynamodb.

zoe-edwards avatar zoe-edwards commented on August 16, 2024

Can you post your code where you call the query?

from laravel-dynamodb.

nam-co avatar nam-co commented on August 16, 2024

Hi I choose to use a regular mysql instead of AWS because all this problems, this is an old issue, But I see people are still having the same issues

from laravel-dynamodb.

zoe-edwards avatar zoe-edwards commented on August 16, 2024

Sorry I meant to tag @krupali-mbarc as they asked the question two days ago on a four year old thread, not the author of the original thread. Hundreds of thousands of queries are made using this framework so I’m not convinced that there is an issue here, other than not understanding how it works. Sorry it didn’t work out for you.

from laravel-dynamodb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.