Some CTP changes in “M”

I did a couple of “Oslo” (now SQL Modeling) presentations at community events in the area in October and November.  My samples used the May CTP, and they broke with the November CTP that came out last week during CTP.  These are the changes needed to bring one of the simple samples (and any of your own “M” code) up to par with the latest CTP.  Here’s a link to the samples from the Tampa CodeCamp presentation: Samples

I haven’t gone through the entire spec document yet, just enough to get these samples compiling to SQL again, so there may be better ways to do some of these things.

So starting at the top, when defining a type and stating lengths for your fields, before you used the “# + number”, like this:

type Presenter

   {

       id : Integer32 => AutoNumber();

       Name: Text#100;

       URL: Text#50;

       Blog: Text#50;

   } where identity(id);

That format is no longer supported, so that same type definition is now: (Notice how the constraints changed)

type Presenter

    {

        id : Integer32 => AutoNumber();

        Name: Text where value.Count <=100;

        URL: Text where value.Count <=50;

        Blog: Text where value.Count <=50;

    } where identity(id);

Or a better, more SQL-like way (thanks Lars):

type Presenter

    {

        id : Integer32 => AutoNumber();

        Name: Text(100);

        URL: Text(50);

        Blog: Text(50);

    } where identity(id);

Then, to define the extent, before you did this:

Presenters:Presenter*;

Now, you have to put curly brackets around it:

Presenters:{Presenter*};

And for the Events extent:

Events:{(Event where value.PresentedBy in Presenters)*};

The reason for that is that they implemented ordered lists, which are represented with square brackets, so we have to specify that we are going for unordered.  Side note, surprisingly enough, they figured out a way to interpret ordered lists in SQL (seems a little odd when i first think about it), take a look here (scroll down to the comments).

Back to our sample model, adding data is still pretty straight forward, just like before, so no changes needed there. 

If you haven’t looked at the new CTP, you definitely should download it and play with it.  There’s some impressive new features, especially a ton of changes to Quadrant that give us productivity right now, even if it’s just CTP.  More on that later…

Here is the entire textual model, which works with the November CTP.  It is very basic, just used to introduce M.  It describes events, presenters, the model data, and adds a couple of transformations. 

module EventsSample

{

    type Event

    {

        id : Integer32 => AutoNumber();   

        Title: Text(100);

        PresentedBy: Presenter;

        Description: Text;

        EventDate:Date;

    } where identity(id);

    

    type Presenter

    {

        id : Integer32 => AutoNumber();

        Name: Text(100);

        URL: Text(50);

        Blog: Text(50);

    } where identity(id);

 

    

    Events:{(Event where value.PresentedBy in Presenters)*};

    Presenters:{Presenter*};

    

    Presenters

    {

        John{

            Name => "John",

            URL => "www.google.com",

            Blog => "www.test.com"

            },

        Mike{

            Name => "Mike",

            URL => "www.microsoft.com",

            Blog => "www.blogger.com"

        }

    }

 

    Events

    {

        {   Title => "Beginning C#",

            PresentedBy => Presenters.John,

            Description => "Talk about C#",

            EventDate => 2009-01-01

        },

        

        {   Title => "Beginning VB",

            PresentedBy => Presenters.Mike,

            Description => "Talk about VB",

            EventDate => 2009-02-01

        }    

    }

 

    UpcomingEvents(n:DateTime){

        from e in Events where e.EventDate > n select e.Title

        }

        

    //View

    PresenterNames() { from p in Presenters select p.Name}

 

}

Scroll to Top