MongoTalk "ns name too long" error

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

MongoTalk "ns name too long" error

Sabine Manaa
Hi,

I try to add the following instance to my MongoDB:

self database addCollection:  '{
    "personnelNumber" : "002",
    "bankAccountNumber" : "45215460",
    "lastName" : "Tester",
    "plz" : "79214",
    "nextTripNumber" : 1,
    "displayBubbleTip" : "some",
    "fax" : "+49-762-34834-99",
    "isEmployer" : false,
    "street" : "Haslacher Strasse 2",
    "blz" : "68050101",
    "tableOfAccounts" : "SKR03",
    "place" : "Freiburg",
    "bankName" : "Comdirekt Bank",
    "subtractPaymentInKind" : true,
    "email" : "sabine.knfffel@fmail.com",
    "creationTimestamp" : "22.02.2013-15:08-72889452",
    "phone" : "+49-762-34834",
    "mobile" : "+49-151-38374637",
    "firstName" : "Theo"
}'

I get this error back from the database:
a Dictionary('code'->10080 'errmsg'->'exception: ns name too long, max size is 128' 'ok'->0.0 )

It seems that MongoDB is trying to add an index (with a field "ns") which is a composition of all my fields:

{
   "v": NumberInt(1),
   "key": {
     "_id": NumberInt(1)
  },
   "ns": "RKA24B.{\r\t \t\"personnelNumber\" : \"002\",\r\t\"bankAccountNumber\" : \"45215460\",\r\t \r........this is longer than 128 sings and causes the error..........}",
   "name": "_id_"
}

Writing above instance to the database DIRECTLY from shell (or with RockMongo) works fine.
What is wrong within Mongotalk? (the testcases work fine because the test objects are small enough) how can I write my instance to the database, how can I avoid that MongoTalk tries to create the index thing?

Adding a line with id
  "_id": "512fff76e79dc751e180c000001",
does not work either.

Sabine
Reply | Threaded
Open this post in threaded view
|

Re: MongoTalk "ns name too long" error

NorbertHartl
Sabine,

addCollection: is used to add a collection to a database. You need add your entry _to_ a collection. So

(self database addCollection: 'mycollection') add: {…}

should work.

Norbert

Am 22.02.2013 um 15:39 schrieb Sabine Knöfel <[hidden email]>:

> Hi,
>
> I try to add the following instance to my MongoDB:
>
> self database addCollection:  '{
>    "personnelNumber" : "002",
>    "bankAccountNumber" : "45215460",
>    "lastName" : "Tester",
>    "plz" : "79214",
>    "nextTripNumber" : 1,
>    "displayBubbleTip" : "some",
>    "fax" : "+49-762-34834-99",
>    "isEmployer" : false,
>    "street" : "Haslacher Strasse 2",
>    "blz" : "68050101",
>    "tableOfAccounts" : "SKR03",
>    "place" : "Freiburg",
>    "bankName" : "Comdirekt Bank",
>    "subtractPaymentInKind" : true,
>    "email" : "[hidden email]",
>    "creationTimestamp" : "22.02.2013-15:08-72889452",
>    "phone" : "+49-762-34834",
>    "mobile" : "+49-151-38374637",
>    "firstName" : "Theo"
> }'
>
> I get this error back from the database:
> a Dictionary('code'->10080 'errmsg'->'exception: ns name too long, max size
> is 128' 'ok'->0.0 )
>
> It seems that MongoDB is trying to add an index (with a field "ns") which is
> a composition of all my fields:
>
> {
>   "v": NumberInt(1),
>   "key": {
>     "_id": NumberInt(1)
>  },
>   "ns": "RKA24B.{\r\t \t\"personnelNumber\" :
> \"002\",\r\t\"bankAccountNumber\" : \"45215460\",\r\t \r........this is
> longer than 128 sings and causes the error..........}",
>   "name": "_id_"
> }
>
> Writing above instance to the database DIRECTLY from shell (or with
> RockMongo) works fine.
> What is wrong within Mongotalk? (the testcases work fine because the test
> objects are small enough) how can I write my instance to the database, how
> can I avoid that MongoTalk tries to create the index thing?
>
> Adding a line with id
>  "_id": "512fff76e79dc751e180c000001",
> does not work either.
>
> Sabine
>
>
>
> --
> View this message in context: http://forum.world.st/MongoTalk-ns-name-too-long-error-tp4671488.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>


Reply | Threaded
Open this post in threaded view
|

Re: MongoTalk "ns name too long" error

Sabine Manaa
Hi Norbert
ah, ok...that works! Thank you!
Sabine

        |theCollection theString|
        theCollection := self database addCollection:   'persons'.
        theString := '{
        "personnelNumber" : "002",
        "bankAccountNumber" : "45215460",
        "lastName" : "Tester",
        "plz" : "79214",
        "nextTripNumber" : 1,
        "displayBubbleTip" : "some",
        "fax" : "+49-762-34834-99",
        "isEmployer" : false,
        "street" : "Haslacher Strasse 2",
        "blz" : "68050101",
        "tableOfAccounts" : "SKR03",
        "place" : "Freiburg",
        "bankName" : "Comdirekt Bank",
        "subtractPaymentInKind" : true,
        "email" : "sabde.ddfel@gmail.com",
        "creationTimestamp" : "23.02.2013-10:39-143192709",
        "phone" : "+49-762-34834",
        "mobile" : "+49-151-38374637",
        "firstName" : "Susi"
}'.
theCollection add: (Dictionary new at: '002' put: theString; yourself).