My Core Data model contains an entity, Shape, that has two self-referential relationships, which means four properties. One pair is a one-to-many relationship (Shape.containedBy <->> Shape.contains) and the another is a many-to-many relationship (Shape.nextShapes <<->> Shape.previousShapes). It all works perfectly in the application, so I don't think self-referencing relationships is a problem in general.
However, when it comes to migrating the model to a new version, then Xcode fails to compile the automatically generated mapping model, with this error message:
2009-10-30 17:10:09.387 mapc[18619:607] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse the format string "FUNCTION($manager ,'destinationInstancesForSourceRelationshipNamed:sourceInstances:' , 'contains' , $source.contains) == 1"'
*** Call stack at first throw:
(
0 CoreFoundation 0x00007fff80d735a4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x00007fff83f0a313 objc_exception_throw + 45
2 Foundation 0x00007fff819bc8d4 _qfqp2_performParsing + 8412
3 Foundation 0x00007fff819ba79d +[NSPredicate predicateWithFormat:arguments:] + 59
4 Foundation 0x00007fff81a482ef +[NSExpression expressionWithFormat:arguments:] + 68
5 Foundation 0x00007fff81a48843 +[NSExpression expressionWithFormat:] + 155
6 XDBase 0x0000000100038e94 -[XDDevRelationshipMapping valueExpressionAsString] + 260
7 XDBase 0x000000010003ae5c -[XDMappingCompilerSupport generateCompileResultForMappingModel:] + 2828
8 XDBase 0x000000010003b135 -[XDMappingCompilerSupport compileSourcePath:options:] + 309
9 mapc 0x0000000100001a1c 0x0 + 4294973980
10 mapc 0x0000000100001794 0x0 + 4294973332
)
terminate called after throwing an instance of 'NSException'
Command /Developer/usr/bin/mapc failed with exit code 6
The 'contains' is the name of one of the self-referential properties. Anyway, the really big problem is that I can't even look at this Mapping Property as Xcode crashes as soon as I select the entity mapping when viewing the mapping model. So I'm a bit lost really where to go from here. I really can't remove the self-referential properties, so I'm thinking I've got manually create a mapping model that compiles? Any ideas?
Cheers
Okay, so it seems as though "contains" might be a reserved word, and as such needs to be escaped using a "#". The Apple docs on migration don't specifically mentions it as a reserved word, although they also don't say what the definitive list is.
But, it seems that a property name cannot be the same as any NSObject or NSManagedObject method name, such as "description", and apparently "contains".
Related
As per the documentation provided,
Office.context.mailbox.item.getSelectedDataAsync(Office.CoercionType.Text, {}, getCallback) supposed to return selected data from body or subject of the mailbox. instead the callback is returning some html markup in asyncResult.value.data, this issue is only in installed outlook.
However this works fine in browser application and it returns the selected data in asyncResult.value.data correctly.
Can someone explain to me why this issue occurs only in installed outlook? Probably I might be missing something, please clarify.
html markup returned instead of selected data:
"<html>\r\n\r\n<head>\r\n<meta http-equiv=Content-Type content=\"text/html; charset=utf-8\">\r\n<meta name=Generator content=\"Microsoft Word 15 (filtered)\">\r\n<style>\r\n<!--\r\n /* Font Definitions */\r\n #font-face\r\n\t{font-family:\"Cambria Math\";\r\n\tpanose-1:2 4 5 3 5 4 6 3 2 4;}\r\n#font-face\r\n\t{font-family:Calibri;\r\n\tpanose-1:2 15 5 2 2 2 4 3 2 4;}\r\n /* Style Definitions */\r\n p.MsoNormal, li.MsoNormal, div.MsoNormal\r\n\t{margin:0cm;\r\n\tmargin-bottom:.0001pt;\r\n\tfont-size:11.0pt;\r\n\tfont-family:\"Calibri\",sans-serif;}\r\na:link, span.MsoHyperlink\r\n\t{color:#0563C1;\r\n\ttext-decoration:underline;}\r\na:visited, span.MsoHyperlinkFollowed\r\n\t{color:#954F72;\r\n\ttext-decoration:underline;}\r\nspan.EmailStyle17\r\n\t{font-family:\"Calibri\",sans-serif;\r\n\tcolor:windowtext;}\r\n.MsoChpDefault\r\n\t{font-family:\"Calibri\",sans-serif;}\r\n#page WordSection1\r\n\t{size:612.0pt 792.0pt;\r\n\tmargin:72.0pt 72.0pt 72.0pt 72.0pt;}\r\ndiv.WordSection1\r\n\t{page:WordSection1;}\r\n-->\r\n</style>\r\n\r\n</head>\r\n\r\n<body lang=EN-IN link=\"#0563C1\" vlink=\"#954F72\">\r\n\r\n<div class=WordSection1>\r\n\r\n<p class=MsoNormal>dheeerldfjshfjdsfs</p>\r\n\r\n</div>\r\n\r\n</body>\r\n\r\n</html>\r\n"
screenshot for reference:
Posting my comment as an answer, as #sudheer reddy has confirmed it.
During your debugging, did you check to see if your app's JavaScript was making the call with Office.CoercionType.Text? If not, change your coercion type accordingly.
I'm a bit new to laravel, but I'm experienced in Php.
In previous works, I set a mecanism that allowed me to be informed when nearly any problem occurred on the server:
I got full stack
precise PHP error messages
for nearly all king of errors
a mail sent to me
So when I began to work with laravel, I tried to do the same things, and achieved:
full stack
a mail sent to me
But I can't have meaningful error in all case. One example:
$store = Store::create(...)
In this line I forget to specify the namespace (\App\Store::create), and I get those error messages:
first:
FatalThrowableError ; Type error: Argument 1 passed to App\Http\Controllers\User::create() must be an instance of Illuminate\Http\Request, array given, called in /var/www/html/laravel/blog/app/Http/Controllers/User.php on line 94
second:
ErrorException ; Trying to get property of non-object in VerifyCsrfToken.php (line 156)
third:
FatalThrowableError ; Type error: Argument 1 passed to Illuminate\Session\Middleware\StartSession::addCookieToResponse() must be an instance of Symfony\Component\HttpFoundation\Response, array given, called in /var/www/html/laravel/blog/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php on line 72
I understand that laravel is a complex framework but I can't figure why it produces this errors, and how I can have more useful errors (as as it is I can only know that "something is bad").
Has someone an idea ?
ยน There is some errors that Php prefers to keep to himself (in its logs) :-)
When you start a new Laravel project, error and exception handling is
already configured for you. The App\Exceptions\Handler class is where
all exceptions triggered by your application are logged and then
rendered back to the user.
https://laravel.com/docs/5.4/errors
I recommend you to dive into the official docs and into your App\Exceptions\Handler.
Maybe you are looking for report and render methods in that class.
I finally cornered the problem and I learned a lot.
I thank for their benevolence #Don't Panic and #Vitalmax !
The error was that I forgot that PHP namespaces are case insensitive: in my post I cleaned a bit the code as I knew that it didn't stick to the code's conventions (a controller's name must begin with a capital letter). Originally my controller name was user and the faulty code was:
$user = User::create(...)
As you can guess PHP believed that I wanted to call user::create (as I have such a method in my controller) and not User::create (as I wanted).
What I learned:
don't alter the code when asking for help
Laravel use a cache system that can get in the way of the debugging (see a question that I asked on laracast's forum )
take more time to read the error message; I know this rule but I keep doing otherwise
I really appreciate any insight anyone can provide.
I've come back to a project that was using the EF6.0 rc preview. After updating the projects EF to 6.1 and updating the SQL Server CE I have two problems.
[UPDATE]
Problems 1 & 2 solved Problem 3 is not.
PROBLEM 3 -
Now with the path set via a connection string as explained above, migrations called via the package manager are not working as its an invalid path. Any ideas anyone?
When I start up the debug process, I get problem 1 and the exceptions crash; but it does create a .sdf file although in the wrong location as explained in problem 2.
1. NOT MAPPED PROPERTY AND UNSUPPORTED BY LINQ ERROR
During the initial creation process I get an exception
List<Equipment> duplicateTags = db.EquipmentReg
.GroupBy(e => e.TagAndLocation)
.Where(g => g.Count() > 1)
.SelectMany(g => g).ToList<Equipment>();
The exception is related to the TagAndLocation. TagAndLocation is defined in the model by
/// <summary>
/// Creates concatenation object that will not be mapped in the database but will be in the
/// Object Relational Mapping (ORM) of the EF model.
/// </summary>
[NotMapped]
public string TagAndLocation { get { return Tag + " (" + Location.Name + ")"; } }
A first chance exception of type 'System.NotSupportedException' occurred in EntityFramework.dll
Additional information: The specified type member 'TagAndLocation' is
not supported in LINQ to Entities. Only initializers, entity members,
and entity navigation properties are supported.
Why is this happening now?
2. CONNECTION STRING NOT APPLYING LOCATION
My connection isn't applying the path properly anymore.
I have it being done by a DbConfiguration class which auto runs, I guess due to its inherited class type. As shown below
class HAIDbJob_EFConfiguration : DbConfiguration
{
public HAIDbJob_EFConfiguration()
{
SetProviderServices(SqlCeProviderServices.ProviderInvariantName, SqlCeProviderServices.Instance);
// Create the connection string programmatically - Setting the filename and path.
SetDefaultConnectionFactory(new System.Data.Entity.Infrastructure.SqlCeConnectionFactory(
"System.Data.SqlServerCe.4.0",
System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Databases"),
#"Data Source=" + System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Databases") +
#"\Hazardous_Area_Database_Job.sdf"));
}
}
Instead of creating a file in the runtime location ...\bin\Debug\Databases\Hazardous_Area_Database_Job.sdf, it creates it at
..\bin\Debug\HA_Inspector.HAI_Database.HAI_Job_EF_Model.Hazardous_Area_Database_Job.sdf
Which is the full namespace of the database model... I have tried a few solutions found for other people problems of a slightly different nature, but none of it works. Any ideas would be extremely appreciate.
1: The EF provider attempt to translate TagAndLocation to SQL and fails. You must use LINQ to Objects for this grouping.
2: Why not have a named connectionstring in your app.config, or pass it in the DbContext constructor.
SOLUTION 1
I did a string compare in the group by statement since location has a string member Location.Name.
SOLUTION 2
When I originally wrote this I wanted to dynamically name the database all the time and this is why I wrote the initialiser class.
To get around the problem, I just followed Erik's advice and put a XAML connection string in app.config using "Source=./Databases"..... to get the subfolder.
I have a test handler with the following:
Model.query().get( projection = [Model.name._name] )
Appstats shows me the following:
(1) 2013-09-29 21:46:38.638 "GET /test" 200 real=2585ms api=0ms overhead=2ms (1 RPC, cost=140, billed_ops=[DATASTORE_READ:2])
According to https://developers.google.com/appengine/docs/billing?csw=1#cost_resource, it should be using 1 read + 1 small for the projected query. Why is it telling me 2 reads (keys_only does use only 1 small)? Also, why is each read a cost of 70 when the docs say 60?
This occurs on both development and production servers.
EDIT: the Model class used is from ndb
What's Model.name._name? Try using Model.name instead.
I have this js code where I am using the Mapstraction library to show GMap and use it's geocoder service via mapstraction as well.
I have recently started getting error 610 whenever I try to issue the geocode service call. The http code is 200 ok however the json returned is as follows:
_xdc_._8gxa9q7ci && _xdc_._8gxa9q7ci( {
"Status": {
"code": 610,
"request": "geocode"
}
})
Chromium's inspector shows the request string as follows:
output:json
oe:utf-8
q:nehru place, , delhi,110048, in
mapclient:jsapi
hl:en
callback:_xdc_._8gxa9q7ci
The issue remains even with a newly generated api key! The map loads just fine with the new key as well as the old key!
So if anyone has run into a similar issue with mapstraction then do let me know the workarounds if any.
Another thing that I have noticed is that my old key is 86 characters long whereas my new key is only 39 characters long. Any insights in this direction would be greatly appreciated. I have spent an entire day trying to get it to work again.
Update: I have noticed that with a key length of 86 characters, the request string has key: MYKEY param as well. Whereas with the 39 character long key, it's not there!
Mapstraction seems to require a 86 character api key to work properly with GMap API v2.
The 36 character API key is for v3 I guess.
If I goto the API console, the 86 character keys generated for my domains isn't shown there. However, the link to generate the 86 character api key is a bit hard to get.
Once generated, my calls to GMap's Geocoder via Mapstraction are working fine now.
Here's the link to generate the v2 API key
http://code.google.com/apis/maps/signup.html
Remember to scroll to the bottom of the page to fill in the correct url.
As for Mapstraction, I think the latest version should be able to use the new 36 character API key!