Support for Polymorphic Associations

I have the following schema:
model Post {
  id            String    @default(cuid()) @id
}

model Comment {
  id            String         @default(cuid()) @id
}

model Vote {
  id            String         @default(cuid()) @id
  item       Post | Comment
}

I'd like to associate the Vote model so that a vote an be created for a Post or a Comment.
As it stands now I have multiple models, PostVote and CommentVote which seems less than ideal.

How would you model this on the database level?

@janpio on database level it could be
CREATE TABLE votes (
  ...
   item_id <what_ever_id_type>,
   item_type VARCHAR -- (or maybe ENUM) Post or Comment value
);

Yes I believe what @shaggyone would work.
@janpio  Is this going to be included in an upcoming release?

No, we are not working on this right now unfortunately. For now you have to build something yourself and work around this.

@janpio Okay, thanks for the update.

@janpio where does this fit on the roadmap for official support?

The current roadmap is more broad: https://www.prisma.io/docs/more/roadmap
This feature currently does not have a concrete plan, so also no ETA.

Closing in favor of: https://github.com/prisma/prisma/issues/2505.

@matthewmueller I think that the lib Ecto from the Elixir ecosystem does a great job at some of the issues of Laravel/Rails way of implementing such relationships, and how we can solve it: https://hexdocs.pm/ecto/polymorphic-associations-with-many-to-many.html
WDYT?

This is great news. I love Prisma, but I couldn't use it because it doesn't support this type of relationship. I'll switch completely when this support comes in.
I hope this work will be completed as soon as possible and we can start using it. Thank you for starting work on this.

Yeah already implemented Prisma assuming polymorphic relationships were a given... ouch.

This issue is 2 years old now and isn't even on the roadmap. I love prisma but I think lately they're concentrating their efforts on the wrong things.

Open source is open source. Make a PR ;-)

@andrewmclagan is not that simple. Prisma is not a random repo floating on GitHub. It is a product, with a team and founding. They do their fair share of advertising around the community too and I think that prisma itself is awesome. What I'm worried about is that it seems like they're focusing resources on making the data proxy platform (which I assume they are gonna monetize in some way) or some other integration without making prisma itself more feature rich. There are a lot of things you can't do today apart from polymorphic relationships. What I'm trying to say here is that I would first try to have a more feature completed, rock solid product before moving away to some other company product. That way it would be a no-brainer for users to go with prisma with out giving it a second thought. For example, we started a new project at my company about two month ago. I suggested prisma but they ended up going with TypeORM because some missing feature. So yeah, I could open a PR but it is easier for me to just pick the right tool for the job. Keep in mind that the prisma team is not composed by contributors but rather full-time employees. Anyways, I don't mean to be the guy that complains, I just think a two year old issue that asks for a solution to a very common problem with no feedback / roadmap whatsoever from the team is not the way to go.

without making prisma itself more feature rich.

Don't worry about that, I think our changes in the last x months (see for example the release notes) or the list of the currently active preview features show that we are still very actively improving Prisma ORM. Polymorphic Associations just did not make the top of our priority list yet. (It would be great if we could do everything at the same time, but that is just not possible.)

@janpio Yes, I follow the release notes and the notion roadmap very closely. I want to be clear on one thing though, I love prisma and I still use it on every side project I have. What bothers me is that I can't suggest prisma to my company for more complex use cases.
What I see on the release notes is more data sources like mongo and cockroach which have been around a long time now (at least mongo), migrations improvements (which are very welcome) and some data proxy stuff (which I've tested myself and it is very cool). Referencial integrity was added for compatibility with plantescale if I'm not mistaken.
The thing is features like polymorphic relationships, geo-spacial queries, recursive queries, proper full-text indexes with algorithms like soundex, grouping by dates (months, years, etc) are the things that make prisma currently incomplete, and those features are very common for any kind of software. I think adding more datasources while shipping the same features is not very wise, quite the contrary, I would rather ship more features and when mature enough, add more datasources and ways to use prisma elsewhere.
Anyways, these are just my thoughts. I know you have limited resources, but I don't think this have to do with resources rather how the team is making the priority list.

Yes, but obviously we also made a conscious decision to prioritize this way in the last few months - it is not that we accidentally ended up like this, but we think this is the best way to make Prisma into a long term successful project.
MongoDB and CockroachDB are now both trending towards GA state, so we will switch back to "only" building features again soon. (Which we never stopped, btw, just the "Client" and "Query Engine" parts needed to focus on these a bit in the last few months - and even there we always try to slip in features when capacity allows).
Make sure all the things you mention have good features requests with good use case description and optimally potential APIs and designs - the better and easier it is to understand a feature, the easier time we have when we tackle these.

Make sure all the things you mention have good features requests with good use case description and optimally potential APIs and designs - the better and easier it is to understand a feature, the easier time we have when we tackle these.

Here is a list of open issues I consider would make prisma a lot more appealing to companies with more complex needs. Most of them have suggestions and ideas on how to implement them.

https://github.com/prisma/prisma/issues/2505 from 2020, 189 likes and several implementation proposal / suggestions.
https://github.com/prisma/prisma/issues/2789 from 2020, 207 likes.
https://github.com/prisma/prisma/issues/3725 from 2020, 46 likes.
https://github.com/prisma/prisma/issues/6653 from 2021, 43 likes.
https://github.com/prisma/prisma/issues/3398 from 2019, 42 likes.

Union Types: Every app comes to a point when some kind of feed or notification system is needed. So you have a model where the relation can be either A, B or C.
PostGIS: Any app working with some kind of geolocation.
Recursive Relations: Any app that has comments or product categories like an e-commerce.
Group by dates: Any app which wants to display a time based chart on the front-end, like a dashboard.
Soft deletes: Any app that don't want to permanently delete records from the database or implement some kind of trash can.
These issues are old enough, useful enough and have enough likes to make it to the roadmap.

Hello, I am new to using APIs and would need to learn how to use GraphQL APIs within Oracle scripts, procedures, and functions. Any resources - preferably tutorial videos on how to invoke GraphQL API to get data, store it into a local Oracle table?
Thank you,
Kamal

I am too missing this set of features. Currently in a table of images which can be connected to several different entities. I tried a few work-arounds but it seems those doesn't work. Please excuse me if I misunderstood something, still getting into Prisma...  I simply cannot add a Image with expenseId > 0 and remarkId null. Those rules are triggered disallowing me to save data.
I ended up with a losely coupled schema which I try to demonstrate by keeping comments in place while waiting for these features to be implemented.

It's funny, I was googling to see if this was solved yet and found the issue I opened. I ran into another instance where I need polymorphic relations.

I ran into another instance where I need polymorphic relations.

@lukehamilton What’s your current workaround for that?

Here is a solution that works for me:
model Profile {
  id String @id @default(uuid())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  title String
  sub String
  desc String
  address String
  tel String
  picture Picture? @relation("ProfilePicture")
}

model Competence {
  id String @id @default(uuid())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  title String
  desc String
  pictures Picture[] @relation("CompetencePicture")
}

model Project {
  id String @id @default(uuid())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  title String
  pres String
  desc String
  techno String
  link String
  picture Picture? @relation("ProjectPicture")
}

enum PicturableType {
  Competence
  Profile
  Project
}

model Picture {
  id String @id @default(uuid())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  name String
  url String
  picturableId String  @unique
  picturableType PicturableType
  Project Project @relation("ProjectPicture", fields: [picturableId], references: [id], map: "project_picturableId")
  Competence Competence @relation("CompetencePicture", fields: [picturableId], references: [id], map: "competence_picturableId")
  Profile Profile @relation("ProfilePicture", fields: [picturableId], references: [id], map: "profile_picturableId")
}

la doc
however it works with postgresql the enums don't work with sqllite so I guess there is another solution for sqllite (but I don't know about it)

Here is a solution that works for me:
model Profile {
  id String @id @default(uuid())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  title String
  sub String
  desc String
  address String
  tel String
  picture Picture? @relation("ProfilePicture")
}

model Competence {
  id String @id @default(uuid())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  title String
  desc String
  pictures Picture[] @relation("CompetencePicture")
}

model Project {
  id String @id @default(uuid())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  title String
  pres String
  desc String
  techno String
  link String
  picture Picture? @relation("ProjectPicture")
}

enum PicturableType {
  Competence
  Profile
  Project
}

model Picture {
  id String @id @default(uuid())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  name String
  url String
  picturableId String  @unique
  picturableType PicturableType
  Project Project @relation("ProjectPicture", fields: [picturableId], references: [id], map: "project_picturableId")
  Competence Competence @relation("CompetencePicture", fields: [picturableId], references: [id], map: "competence_picturableId")
  Profile Profile @relation("ProfilePicture", fields: [picturableId], references: [id], map: "profile_picturableId")
}

la doc
however it works with postgresql the enums don't work with sqllite so I guess there is another solution for sqllite (but I don't know about it)

If this works, it is essentially a polymorphic relation and this issue can be closed!

@tonyea it’s not an ideal solution as every time a new row is created in the Picture table you end up with null columns

@tonyeace n'est pas une solution idéale car chaque fois qu'une nouvelle ligne est créée dans le Picturetableau, vous vous retrouvez avec deux nullcolonnes

oh yes sorry, I forgot them? for it to work properly. I modified my code. Effectively this returns 2 null columns. I don't know if there is a solution without having null columns.

Hello,
After many tests my code above does not work. so i redid my code, i didn't want to leave something not working on github, here is my fix (which works this time)
I reviewed my logic because it was not good and therefore I leave the polymorphic case, so this code will bring you nothing but I wanted to clarify what I published.
some explanation:
my skills have several images, but profile and project have only one image, so I modified my tables:
skill n : 1 picture
project 1 : 1 picture
profile 1 : 1 picture
Here is the prisma code:
model Profile {
  id String @id @default(uuid())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  title String
  sub String
  desc String
  address String
  tel String
  pictureId String? @unique
  picture Picture? @relation(fields: [pictureId], references: [id])
}

model Competence {
  id String @id @default(uuid())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  title String
  desc String
  pictures Picture[]
}

model Project {
  id String @id @default(uuid())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  title String
  pres String
  desc String
  techno String
  link String
  pictureId String? @unique
  picture Picture? @relation(fields: [pictureId], references: [id])
}

model Picture {
  id String @id @default(uuid())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  name String
  url String
  competenceId String?
  competence Competence? @relation(fields: [competenceId], references: [id])
  project Project?
  profile Profile?
}

this solution works for postgresql and sql lite
again there are null columns in all cases, I don't think it's a problem, there are always null columns in the database.
here is no polymorphic solution but at least the code above works ^^ .
if I come across a case where the polymorphic seems more appropriate to me, I will share my code, if the solution exists ^^
good for you

Here is a solution that works for me:
model Profile {
  id String @id @default(uuid())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  title String
  sub String
  desc String
  address String
  tel String
  picture Picture? @relation("ProfilePicture")
}

model Competence {
  id String @id @default(uuid())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  title String
  desc String
  pictures Picture[] @relation("CompetencePicture")
}

model Project {
  id String @id @default(uuid())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  title String
  pres String
  desc String
  techno String
  link String
  picture Picture? @relation("ProjectPicture")
}

enum PicturableType {
  Competence
  Profile
  Project
}

model Picture {
  id String @id @default(uuid())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  name String
  url String
  picturableId String  @unique
  picturableType PicturableType
  Project Project? @relation("ProjectPicture", fields: [picturableId], references: [id], map: "project_picturableId")
  Competence Competence? @relation("CompetencePicture", fields: [picturableId], references: [id], map: "competence_picturableId")
  Profile Profile? @relation("ProfilePicture", fields: [picturableId], references: [id], map: "profile_picturableId")
}

la doc
however it works with postgresql the enums don't work with sqllite so I guess there is another solution for sqllite (but I don't know about it)

now work for Mysql :(

Another (not so great) work around is to take care of the polymorphic relationship management in the application layer:
generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model Post {
  id    Int    @id @default(autoincrement())
  title String
}

model Page {
  id    Int    @id @default(autoincrement())
  title String
}

enum TaggableType {
  Page
  Post
}

model Tag {
  id           Int          @id @default(autoincrement())
  taggableId   Int
  taggableType TaggableType
}

import { PrismaClient, Tag, Post, Page } from "@prisma/client";

const prisma = new PrismaClient();

type Taggable = Post | Page;

/**
 * Get taggable for a tag
 */
function getTaggable(tag: Tag): Promise<Taggable> {
  if (tag.taggableType === "Post") {
    return prisma.post.findUniqueOrThrow({ where: { id: tag.taggableId } });
  }

  if (tag.taggableType === "Page") {
    return prisma.page.findUniqueOrThrow({ where: { id: tag.taggableId } });
  }

  throw new Error("Invalid taggable type.");
}

/**
 * Get tags for a taggable
 */
async function getTags(taggableId: number) {
  return prisma.tag.findMany({ where: { taggableId } });
}

Also possible to manually add constraints and cascades:
ALTER TABLE `Tag` ADD CONSTRAINT `TagPage_taggableId_fkey` FOREIGN KEY (`taggableId`) REFERENCES `Page`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `Tag` ADD CONSTRAINT `TagPage_taggableId_fkey` FOREIGN KEY (`taggableId`) REFERENCES `Page`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

Disclaimer: sorry in advance for the negative comment
I was uncertain about posting this negative feedback, but I figured the Prisma team should be aware of how much grief they have caused my team and probably other ones.
In the last few years, I have seen a lot articles and podcasts speaking highly of Prisma.
So i decided to give it a try on a few small scale side projects and the DX was great.
More recently, when I created my company, I did a deep benchmark of the ecosystem before choosing my ORM.
From a theoretical point of view Prisma seemed like a perfect fit: a modern ORM, fully typed, backed by a well funded company and supposed to be production ready.
After investing months of work with several engineers, we had the same experience as @andrewmclagan.
We started to discover that Prisma was lacking basic features.
It might have a great DX but it's not fit for a production, real-world application.
The polymorphic association is a perfect example of that: it's a basic, standard, must have feature that any real-world application ends up having.
So, to be honest I feel betrayed by the shiny marketing of Prisma.
Usually most open source projects not backed by companies emphasize their limitations and their missing features.
They know that if users have to back away after investing tens of thousands of dollars, they are going to develop strong feelings against them. It doesn't make sense to force people to use their project because are not making any profit from it.
I thought that a project backed by a company (dedicated to the project) was a good sign but I'm starting to think otherwise.
I not so sure anymore that Prisma's interests are aligned with the users'.
Sorry again for the harsh feedback, but I would be happy to discuss in more details with the Prisma team.

@leonard-henriquez the same thing happened to me although I still use prisma for side / toy projects.  It has a similar dx but it gives you the full power of the db.

Hey @leonard-henriquez, thanks so much for sharing your feedback with us!

Disclaimer: sorry in advance for the negative comment

No need to be sorry, in fact it's much appreciated that you share it since that gives us an opportunity to improve 🙏
It would be awesome if you could send me an email (on my GH profile page) so we can arrange a chat.
Many thanks from the Prisma team!

ON DELETE CASCADE

Adding multiple constraint using same column possible but not usable for relational database. Considering above example, taggableId can be either a Page or Post but not both at same time, therefore, same taggableId won't be present in both Post and Page at same time. Hence, any DB insert to page or post will fail with foreign key constraint.

Another work around is to take care of the polymorphic relationship management in the application layer:

Database layer 🔴
Prisma layer 🔴
Application layer 🟢

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model Post {
  id    Int    @id @default(autoincrement())
  title String
  // Prisma lacks support for polymorphic relations and union types :-(
  // tags Tag[]
}

model Page {
  id    Int    @id @default(autoincrement())
  title String
  // Prisma lacks support for polymorphic relations and union types :-(
  // tags Tag[]
}

enum TaggableType {
  Page
  Post
}

model Tag {
  id           Int          @id @default(autoincrement())
  taggableId   Int
  taggableType TaggableType
  // Prisma lacks support for polymorphic relations and union types :-(
  // taggable Page | Post
}

import { PrismaClient, Tag, Post, Page } from "@prisma/client";

const prisma = new PrismaClient();

type Taggable = Post | Page;

/**
 * Get taggable for a tag
 */
function getTaggable(tag: Tag): Promise<Taggable> {
  if (tag.taggableType === "Post") {
    return prisma.post.findUniqueOrThrow({ where: { id: tag.taggableId } });
  }

  if (tag.taggableType === "Page") {
    return prisma.page.findUniqueOrThrow({ where: { id: tag.taggableId } });
  }

  throw new Error("Invalid taggable type.");
}

/**
 * Get tags for a taggable
 */
async function getTags(taggableId: number) {
  return prisma.tag.findMany({ where: { taggableId } });
}

Also possible to manually add constraints and cascades:
ALTER TABLE `Tag` ADD CONSTRAINT `TagPage_taggableId_fkey` FOREIGN KEY (`taggableId`) REFERENCES `Page`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

ALTER TABLE `Tag` ADD CONSTRAINT `TagPost_taggableId_fkey` FOREIGN KEY (`taggableId`) REFERENCES `Post`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

RANT The more our team uses Prisma the more we realise its a well marketed but unfinished product. There are so many basic fundamental features of an ORM that Prisma is missing. We have lost all confidence in the product after initially investing a lot of time we are now considering rewriting our data layer into another ORM. Its hard to understand why basic features are not being prioritised over others that seem incredibly arbitrary.
It has so much potential, what it actually does it does it well, open-source community appreciates such projects but...
Don't market Prisma as a finished product when its not. That is misleading.

Adding multiple constraint using same column possible but not usable for relational database. Considering above example, taggableId can be either a Page or Post but not both at same time, therefore, same taggableId won't be present in both Post and Page at same time. Hence, any DB insert to page or post will fail with foreign key constraint.

Crazy that this is still open for such a commonly used feature in real world applications. I opened this issue before Covid started 🫠.
It's my most popular GH issue so I take solace in that. Hope we can get this feature shipped in 2023 🥳.

Imagine not giving your users something they are begging for

Imagine not giving your users something they are begging for

It's open source, if you want it so badly go ahead and submit a PR.

I am satisfied with everything while using Prisma, but I hesitate to use it because Prisma does not support polymorphic relationships.
Does the Prisma team have any plans to develop this in the future? I'd like to know a clear official position.

Yes, we will definitely look at implementing this in the future. But we can not say yet when that will happen and then be released.

I've been using Laravel for 8+ years and many of my projects extensively use many-to-many polymorphic relations. Recently, I was exploring Next.js so that I can make entire projects in one language and explored the ORMs. Chose Prisma as it seemed to have great DX, and was flashier compared to other websites and demos. 5-6 days into my code port from Laravel's Eloquent to Prisma, and I've hit a roadblock with the associations, and I'm now forced to look for alternatives. It would be great to see this implemented in Prisma.

Came across this today and the only thing that worked for me was a combination of this reply:

Hello,
After many tests my code above does not work. so i redid my code, i didn't want to leave something not working on github, here is my fix (which works this time)
I reviewed my logic because it was not good and therefore I leave the polymorphic case, so this code will bring you nothing but I wanted to clarify what I published.
some explanation: my skills have several images, but profile and project have only one image, so I modified my tables:
skill n : 1 picture project 1 : 1 picture profile 1 : 1 picture
Here is the prisma code:
model Profile {
  id String @id @default(uuid())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  title String
  sub String
  desc String
  address String
  tel String
  pictureId String? @unique
  picture Picture? @relation(fields: [pictureId], references: [id])
}

model Competence {
  id String @id @default(uuid())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  title String
  desc String
  pictures Picture[]
}

model Project {
  id String @id @default(uuid())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  title String
  pres String
  desc String
  techno String
  link String
  pictureId String? @unique
  picture Picture? @relation(fields: [pictureId], references: [id])
}

model Picture {
  id String @id @default(uuid())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  name String
  url String
  competenceId String?
  competence Competence? @relation(fields: [competenceId], references: [id])
  project Project?
  profile Profile?
}

this solution works for postgresql and sql lite again there are null columns in all cases, I don't think it's a problem, there are always null columns in the database.
here is no polymorphic solution but at least the code above works ^^ .
if I come across a case where the polymorphic seems more appropriate to me, I will share my code, if the solution exists ^^
good for you

the usage of the Prisma relation-mode instead of the PostgreSQL foreign keys. This is a horrible solution. I just hope that at some point Prisma will catch up on this.

At work, we stopped using Prisma for the many reasons other people have stated.

We created an alternative workaround using Prisma client's extensions feature. For the demo, I used the model shared by @nitinmuk .
import { Page, Post, Prisma, PrismaClient, Tag } from "@prisma/client";

type PageExtended = Page & { tags: Tag[] };

const prisma = new PrismaClient();

const xprisma = prisma.$extends({
  name: `polymorphism`,
  query: {
    page: {
      // Needs Prisma >= v4.7.0. Note: we need to cast the returned type in main().
      async findUnique({ args, query }): Promise<Partial<PageExtended>> {
        const page = await query(args);
        const tags = await prisma.tag.findMany({
          where: { taggableId: args.where.id },
        });

        return { ...page, tags };
      },
    },
  },
  model: {
    tag: {
      // Needs Prisma >= v4.9.0.
      async findFirstWithPolymorphism<
        Args extends Prisma.Args<T, "findFirst"> & {
          includeTaggable?: boolean;
        },
        T extends typeof prisma.tag
      >(
        this: T,
        args: Args
      ): Promise<
        | (Prisma.TagGetPayload<Prisma.TagArgs> &
            (Args["includeTaggable"] extends true
              ? NonNullable<Args["where"]>["taggableType"] extends "Post"
                ? {
                    post?: Post | null;
                  }
                : NonNullable<Args["where"]>["taggableType"] extends "Page"
                ? {
                    page?: Page | null;
                  }
                : {}
              : {}))
        | null
      > {
        const taggableId = args.where?.taggableId;
        const taggableType = args.where?.taggableType;

        const { includeTaggable } = args;
        delete args.includeTaggable;

        const tag = await this.findFirst(args);

        if (!tag) {
          return null;
        }
        if (taggableId == null) {
          return tag;
        }
        if (typeof taggableId !== "number") {
          throw new Error(
            "Provide a taggabled id number, object filters are not allowed."
          );
        }

        if (includeTaggable && taggableType === "Post") {
          const post = await prisma.post.findUnique({
            where: { id: taggableId },
          });
          return { ...tag, post };
        }
        if (includeTaggable && taggableType === "Page") {
          const page = await prisma.page.findUnique({
            where: { id: taggableId },
          });
          return { ...tag, page };
        }

        return tag;
      },
    },
  },
});

async function main() {
  const page = (await xprisma.page.findUnique({
    where: { id: 0 },
  })) as PageExtended | null;
  console.log("page is: ", page);

  const tagWithRelations = await xprisma.tag.findFirstWithPolymorphism({
    where: { id: 10, taggableType: "Post", taggableId: 0 },
    includeTaggable: true,
  });
  console.log("tagWithRelations is: ", tagWithRelations);
}

main();

Well, this has been a huge slap in the face. Likes, Comments, Versioned columns, all this jackpot I've implemented in my schema only to realise it wont work :(

The question now until they make an effort, what alternative to Prisma currently solves these problems?

@AxelBriche I'm pretty happy with edgedb

Does this suggestion not work? Marking the relationships with a map? Or does it only work with postgresql, and not with other DBs?
https://github.com/prisma/prisma/discussions/11108

This issue is in my top 5 reasons to stop using prisma. I've been using prisma in my work for 2.5 years, and there are many basic features missing, but this one tops the list. This feature is a requirement for anyone who has a database with models such as assets (image, video, file) or interactions (likes, comments, shares) that join with multiple tables (post, profile, product). I still think prisma has the best node.js API for SQL, but this issue might be a dealbreaker the next time I'm building a DB.

Personally looking into Drizzle & Kysely as Prisma feels too lock-iny 🔒

The SQL-like syntax of Drizzle makes more sense to me and easier to work with

I'm going to unsubscribe from this issue since it has been three years now and there are no signs of it being near the roadmap. I hope the prisma team will consider listening a bit more to their users and deliver those basic missing features that we've been asking for years. With so many other cool projects such as edgedb or surrealdb, I don't think prisma can afford to stay still feature wise. Only time will tell.

i like prisma but without this not sure if i'm gona use it anymore.

@floelhoeffel four months ago when I discussed with you and the Prisma team you mentioned that you were on the verge to publish a documentation on how some teams succeeded to support polymorphic associations with Prisma extensions.
Is it still planned? Do you have any insights when it will be?
Thanks in advance !

@leonard-henriquez there is definitely an angle to polymorphic relations via extensions - at least on the Prisma client / code level. I haven't seen anyone publish content around it yet but we would love a pull request to https://github.com/prisma/prisma-client-extensions in case someone has bandwidth to explore this area 🙏

@janpio does this label means that are you taking an interest on this topic? 🥳 🎉 😍
Just to sum up there are several issues related to polymorphism left un-answered:

https://github.com/prisma/prisma/issues/1644 (55 comments and a few hundreds upvotes)
https://github.com/prisma/prisma/issues/253 (20 comments)
https://github.com/prisma/prisma/issues/2505 (73 comments and more than 500 hundreds on the first message only)
https://github.com/prisma/prisma/issues/2506 (11 comments)
https://github.com/prisma/prisma/issues/4173
https://github.com/prisma/prisma/issues/15554

I am fully available days and nights if you want to have some insight on:

how it's a major blocking issue for any SaaS product that need tags, comments, files (or any model that need to be shared across the codebase) because they are no hints of solutions (even dirty ones)
what would be necessary to unblock this situation

@janpio

We would love to work on it. But not possible in this moment.

Genuinely curious as to what is needed to maybe help this along?

Straightforward answer is that you can't. No one here is available to jump into any discussions right now, no one is available to review any PRs that try to partially implement this, and no one is available right now to start the design or implementation work. (If you can help out in other issues to make sure the problem is described, a minimal reproduction is available and so on that theoretically saves us some time - but that only very indirectly translates to benefits for this set of issues.)

@janpio -- Polymorphic associations were added to Rails 1.1 in March 2006. I understand Prisma needs to monetize and that will be easier with new paid features, but can't we at least add polymorphic to the roadmap?

To sumup :

It's a standard feature (it's in sequelize, it was in Rails 1.1, etc)
It's a blocking feature: there is no documented (or even undocumented) workaround
It's one the most virulent issue (top 1% of the most active issues of this repo ever)
There is no ETA
There's nothing we can do to accelerate this process

@janpio  what does the Prisma team advice to a team that needs polymorphic association ?

To sumup :

It's a standard feature (it's in sequelize, it was in Rails 1.1, etc)
It's a blocking feature: there is no documented (or even undocumented) workaround
It's one the most virulent issue (top 1% of the most active issues of this repo ever)
There is no ETA
There's nothing we can do to accelerate this process

@janpio what does the Prisma team advice to a team that needs polymorphic association ?

I'm not from Prisma and this solution is not not ideal, but it worked for me, no complaints.
Allows me to keep likes for both Comments and Pictures in the same table.
model Like {
  id                      String  @id @default(cuid())
  pictureId          String?   // Either this is not null
  commentId      String?   // or this
  userId               String    // user who liked

  user              User               @relation(fields: [userId], references: [id], onDelete: Cascade)
  picture         Picture?          @relation(fields: [pictureId], references: [id], onDelete: Cascade)
  comment     Comment?     @relation(fields: [commentId], references: [id], onDelete: Cascade)

  @@unique([pictureId, userId])
  @@unique([commentId, userId])
}

Thank you @anri-asaturov but it's not really an option when your "Like" table can be related to 10+ other tables:

It's hard to maintain constraints to have exactly one id that is not null (pictureId  XOR commentId  XOR ...)
You need to add tons of conditions everywhere which introduce a lot of tech debt
It's not typesafe
Joins become very very verbose

I follow the db structure of Laravel's ORM when it comes to doing this as a workaround in Prisma.
model Post {
  id             String  @id @default(cuid())
  title          String
  ...
 }

model Comment {
  id             String  @id @default(cuid())
  body        String
  ...
}

enum LikeType {
  Comment
  Post
}

model Like {
  id                    String  @id @default(cuid())
  likeableType   LikeType @default(Post);
  likeableId       String
}

Then I just do a separate query on Like table to grab likes for whatever resource I'm getting be it a Comment or Post.

Polymorphic Associations announced in Prisma 17. Expected release: 2031.

I follow the db structure of Laravel's ORM when it comes to doing this as a workaround in Prisma.
model Post {
  id             String  @id @default(cuid())
  title          String
  ...
 }

model Comment {
  id             String  @id @default(cuid())
  body        String
  ...
}

enum LikeType {
  Comment
  Post
}

model Like {
  id                    String  @id @default(cuid())
  likeableType   LikeType @default(Post);
  likeableId       String
}

Then I just do a separate query on Like table to grab likes for whatever resource I'm getting be it a Comment or Post.

Is this method possible with a database that doesn't support enums? I'm using MSSQL

Any update on this topic?

@janpio I need to make a tech decision for my company. Either to go on with Prisma or to switch to another ORM.
The amount of monkey patching  and work around we have in the code base because of this lack of support for Polymorphism and UnionType has reach its threshold of maintainability.
Will this feature make it in the priorities in the coming 6 months ?

 There has been no evidence this is a priority or will be in the near future, as unfortunate as that is.

To be honest, this is a must feature for any medium+ sized project. Currently, you have to either:

Make tons of specific tables just to comply to prisma relation capabilities (which is extremely bad practice and so hard to maintain).
Write raw sql to join and fetch the data which basically makes prisma obsolete in the first place.
Write additional queries to join the data in code (which is terrible for maintenance). Furthermore, you might have upwards of 5 such relations for a single query/entity which make complexity unbearable.
Needless to say, all of them are terrible workarounds.

 There has been no evidence this is a priority or will be in the near future, as unfortunate as that is.

This is so sad ! I love Prisma, but it's not really an option for "real life production projects" then. How do you guys work-around this in your projects (real business projects I mean) ?

I mean, don't we all have a Media table that is related to multiple other objects (a message, a contact, ...) ?
A notification or activity feed that can be of many types ?
An address table that is either related to a person, a company, or a credit card ?

I can't believe that Prisma is only used for side projects and POC ! How is everyone else doing ?

 There has been no evidence this is a priority or will be in the near future, as unfortunate as that is.

This is so sad @piesrtasty ! I love Prisma, but it's not really an option for "real life production projects" then. How do you guys work-around this in your projects (real business projects I mean) ?

I mean, don't we all have a Media table that is related to multiple other objects (a message, a contact, ...) ?
A notification or activity feed that can be of many types ?
An address table that is either related to a person, a company, or a credit card ?

I can't believe that Prisma is only used for side projects and POC ! How is everyone else doing ?

Let alone the business context, you can't even have a simple Tags table.

We don't use prisma for production stuff because of this. :(

We don't communicate concrete dates, so I also can't promise we will get to this in the next 6 months. If you absolutely need this, your better choice is indeed to use another tool. We hope to win you back when we implement this in the future.

While there are a number of missing features in Prisma that don't have a good workaround, this doesn't seem like one to me? In the case of a 1:many like comments, create a commentable table such that, say, post and video have a 1:1 with commentable and then the commentable record has 1:many with comments:
model Post {
  id String  @id @default(cuid())
  commentableId String
  commentable Commentable @relation(fields: [commentableId], references: [id])
}

model Video {
  id String  @id @default(cuid())
  commentableId String
  commentable Commentable @relation(fields: [commentableId], references: [id])
}

model Commentable {
  id String  @id @default(cuid())
  comments Comment[]
  post Post
  video Video
}

model Comment {
  id String  @id @default(cuid())
  commentableId String
  commentable Commentable @relation(fields: [commentableId], references: [id])
}

For a many:many like tags, add a join table
model Post {
  id String  @id @default(cuid())
  taggableId String
  taggable Taggable @relation(fields: [taggableId], references: [id])
}

model Video {
  id String  @id @default(cuid())
  taggableId String
  taggable Taggable @relation(fields: [taggableId], references: [id])
}

model Taggable {
  id String  @id @default(cuid())
  tagSet tagSet[]
  post Post
  video Video
}

model TagSet {
  id String  @id @default(cuid())
  taggableId String
  taggable Taggable @relation(fields: [taggableId], references: [id])
  tagId String
  tag Tag @relation(fields: [tagId], references: [id])
}

model Tag {
  id String  @id @default(cuid())
  tagSets TagSet[]
}

While it does mean you can potentially have "orphan" commentable/taggable entries that aren't connected to anything, I think that's preferable over not having a foreign key to ensure the validity of the relationship. And when querying "in reverse" you do still have to have sparse reverse relations (ie, in TS, not in the DB), but since you don't know what is on the other side anyways, that seems reasonable. I suppose returning a single item as a union would be a bit cleaner, but again personally I'd prefer having that foreign key. Minimally, this allows you to properly query the relation without a large number of null columns.

We can't help but feel genuinely disappointed ...

I am responding to this message in a discussion, as it is not related to support of Polymorphic Associations at all and will be irrelevant for everyone subscribed to this issue: https://github.com/prisma/prisma/discussions/21099 Please, redirect any further responses to this to the GitHub discussion instead. Keep this comment thread for responses to the support of Polymorphic Associations. Thank you.

@janpio any news or plans you could share here?

No change since I posted above 1 month ago: https://github.com/prisma/prisma/issues/1644#issuecomment-1720133760

I was a subscriber to this issue for a year, now it is time to move on. I can't wait my whole life. Maybe, someday, my sun could come here and see that this is added. Goodbye for now.

I was a subscriber to this issue for a year, now it is time to move on. I can't wait my whole life. Maybe, someday, my sun could come here and see that this is added. Goodbye for now.

It's been so long that it's kind of fun at this point, like how long can they go without adding this feature.

Hey I just found out about this thread. Would love to be part of the discussion :)

@janpio but maybe you could explain why?
Looking at this thread it is clear this is something people need, and when we combine that with the fact you guys are shipping stuff fairly frequently - it is sort of astounding to not have an ETA or at least a clear commitment.

@janpio based on the discussion here - https://github.com/prisma/prisma/discussions/21099 you mentioned you're open to proposals for implementation? Happy to delve into this if the submission will be taken seriously post the next milestone release (which I assume is 5.5?)

@simonsan here's how you can do polymorphic associations in drizzle https://github.com/drizzle-team/drizzle-orm/issues/1051#issuecomment-1783962092
And here a possible solution in rdb
https://github.com/alfateam/rdb/issues/58#issuecomment-1786689002
Haven't really looked into TypeORM

@simonsan actually most ORMs support polymorphic associations

ORM name
Polymorphic Relationship supported

Prisma
❌

Drizzle
🆗  (solution here)

TypeORM
🆗  (through this package)

MikroORM
✅ (doc here)

Sequelize
✅ (doc here)

Bookshelf.js
✅ (doc here)

Objection.js
✅ (doc here)

Hey guys! We are building ZenStack on top of Prisma. One of ZenStack's goals is to enhance the Prisma schema by adding features like access policies, customer attributes and model inheritance.  Polymorphism is our next target.
We understand that this is a non-trivial task, so before proceeding with the implementation, we have written a post to explain our approach. We would greatly appreciate hearing your opinions on it:
https://zenstack.dev/blog/polymorphism
Please leave your thoughts about the proposal in this GitHub issue or simply join our Discord to chat.

@jiashengguo is this what we call the christmas magic? 😍

Hi, this is indeed an important feature for anyone who works on a forum-like system where Like, Favourite can assoiate with many tables like Post, Comment, Category, Topic, etc.
I believe this was an essential feature since that majority of ORMs for Node.JS have this feature. Recently I have migrated to Prisma and found out prisma does not have this feature supported. As well as custom value ENUM support.
I hope you guys can put this into the roadmap, so we can hope for it. Without this feature, I think many others have to choose another ORMs.

Would like to see this too. Not having this feature will be a major issue if my project scales.

It's been 4 years. I don't think we're gonna get this feature.

@ian prisma is no longer the energetic prisma 2020

Not an advertisement, but I would like to suggest Prisma's team to take a look at Sequelize's document and source code, they have done a perfect job in explaining and developing polymorphic assosication. Sequelize support three types of polymorphic association. I believe Single-model, single-foreign-key polymorphic associations is the more common way to achieve it using a type field and an id field which I have mentioned above.

this is still open for 4 years.. sheesh.
this issue is very similar to another one I ran into with prisma-- being able to split my schema which should be a given.
https://github.com/prisma/prisma/issues/2377
Also been open for 4 years.
from the comments of both this issue and the one i listed here, community has noticed the huge shift towards monitization- away from basic maintaince of prisma
rip

While there are a number of missing features in Prisma that don't have a good workaround, this doesn't seem like one to me? In the case of a 1:many like comments, create a commentable table such that, say, post and video have a 1:1 with commentable and then the commentable record has 1:many with comments:
model Post {
  id String  @id @default(cuid())
  commentableId String
  commentable Commentable @relation(fields: [commentableId], references: [id])
}

model Video {
  id String  @id @default(cuid())
  commentableId String
  commentable Commentable @relation(fields: [commentableId], references: [id])
}

model Commentable {
  id String  @id @default(cuid())
  comments Comment[]
  post Post
  video Video
}

model Comment {
  id String  @id @default(cuid())
  commentableId String
  commentable Commentable @relation(fields: [commentableId], references: [id])
}

For a many:many like tags, add a join table
model Post {
  id String  @id @default(cuid())
  taggableId String
  taggable Taggable @relation(fields: [taggableId], references: [id])
}

model Video {
  id String  @id @default(cuid())
  taggableId String
  taggable Taggable @relation(fields: [taggableId], references: [id])
}

model Taggable {
  id String  @id @default(cuid())
  tagSet tagSet[]
  post Post
  video Video
}

model TagSet {
  id String  @id @default(cuid())
  taggableId String
  taggable Taggable @relation(fields: [taggableId], references: [id])
  tagId String
  tag Tag @relation(fields: [tagId], references: [id])
}

model Tag {
  id String  @id @default(cuid())
  tagSets TagSet[]
}

While it does mean you can potentially have "orphan" commentable/taggable entries that aren't connected to anything, I think that's preferable over not having a foreign key to ensure the validity of the relationship. And when querying "in reverse" you do still have to have sparse reverse relations (ie, in TS, not in the DB), but since you don't know what is on the other side anyways, that seems reasonable. I suppose returning a single item as a union would be a bit cleaner, but again personally I'd prefer having that foreign key. Minimally, this allows you to properly query the relation without a large number of null columns.

How would you approach cascade delete scenario for these relations? Deleting Video/Post should delete all related comments. The case for many-to-many is even more dire.

Unfortunately, you don't get the benefit of cascade deletes here. As I noted:

While it does mean you can potentially have "orphan" commentable/taggable entries that aren't connected to anything, I think that's preferable over not having a foreign key to ensure the validity of the relationship.

Also worth keeping in mind that a sparse table is the only way to do this where you would get db-level cascade deletes - if Prisma would provide cascade deletes here, it would be emulated. This limitation is the same with any 1-1 relationship - foreign keys can only be created on one side, so you can't get cascade deletes in both directions.

Just read this entire thread. L O L. And still not on the roadmap. Good thing drizzle figured this out and went through a beta, all in less than a year of being asked about it.
ref: https://github.com/drizzle-team/drizzle-orm/issues/207
Guess I'm moving my company away from Prisma (-> Drizzle) as well. Honestly really sad as I was just getting really used to Prisma after ~6-9mos of using it.

Also just found this from keinsell's external issue above... - hilarious
https://github.com/keinsell/is-prisma-production-ready

Would love to have this feature implemented so I can recommend using Prisma at work.

The current roadmap is more broad: https://www.prisma.io/docs/more/roadmap This feature currently does not have a concrete plan, so also no ETA.

@janpio Where is the roadmap now for polymorphism? It has been 2 years.

Just read this entire thread. L O L. And still not on the roadmap. Good thing drizzle figured this out and went through a beta, all in less than a year of being asked about it.
ref: drizzle-team/drizzle-orm#207
Guess I'm moving my company away from Prisma (-> Drizzle) as well. Honestly really sad as I was just getting really used to Prisma after ~6-9mos of using it.

Saying Drizzle figured this out is not quite true:
https://github.com/drizzle-team/drizzle-orm/issues/1051
Drizzle implemented some nice Set operations but their docs do not have any mention of polymorphism.

After using Prisma for 2 years for various personal projects, it just never occurred to me that it doesn't support for polymorphic relations, which IMO should be tablestakes for all ORMs. TBH quite surprising to see a 4 year long thread. with no positive outcome.
Any updates on prioritization on the roadmap?

Hi guys, I'm from the future in 2095 and we don't have this feature still. We mostly come to this issue to socialize now.

This is great. At this point I hope we never get it. This whole situation is so ridiculous at this point that you gotta just laugh and embrace it. 😃

Just read this entire thread. L O L. And still not on the roadmap. Good thing drizzle figured this out and went through a beta, all in less than a year of being asked about it.
ref: drizzle-team/drizzle-orm#207
Guess I'm moving my company away from Prisma (-> Drizzle) as well. Honestly really sad as I was just getting really used to Prisma after ~6-9mos of using it.

+1 for this.

Would love to have this feature implemented so I can recommend using Prisma at work. Is there any "official" recommendation on a workaround for this? Would be cool if Prisma offered some documentation on how they'd handle polymorphism in the classic "votes" case, so that users can take inspiration from that.

+1 for this.


I can't view the app anywhere.

Solution suggestion: deploy the front-end.

@johnoro is this still an issue? The front end is deployed on Netlify. https://joinourbigday.netlify.com/#/


Create Project.toml, drop REQUIRE

You can probably just drop the failing 0.6 and 0.7 jobs at this point

It would also be nice if you could update the docs deployment with a Project file.

@JuliaRegistrator register()

Pull request comments will not trigger Registrator as it is disabled. Please trying using a commit or issue comment.


coding guidelines: comply with MISRA C:2012 Rule 4.1

MISRA C:2012 Rule 4.1 (Octal and hexadecimal escape sequences shall be
terminated.)
Use string literal concatenation to properly terminate hexadecimal
escape sequences.
Signed-off-by: Abramo Bagnara<EMAIL_ADDRESS>

interesting, so checkpatch WARNING:STRING_FRAGMENTS violates misra


[Beam-9543] Support Match Recognition in Beam SQL

Changes since the last PR:

Solved serialization issues and coder issues.
Used Java Regex library to support pattern matching without back-reference (quantifiers not supported for now).
Passed a simple test case (more test cases to be added soon).
Fixed code style.

Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

[ ] Choose reviewer(s) and mention them in a comment (R: @username).
[ ] Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
[ ] Update CHANGES.md with noteworthy changes.
[ ] If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

R: @amaliujia

@Mark-Zeng thanks for your update on this PR. Let me know when you think this PR is ready for review again.

Hi Mark-Zeng :-) Just wanted to say thanks for the good work! SQL Pattern matching is going to be awesome to have in Beam.
Regards from Stockholm, Sweden
Dan

@Mark-Zeng
Thanks for your update.

Also, can you rebase your PR against the head of the main branch?

Interesting. I used the squash and merge button but it seems just create a merge pull request. It might not matter that much.


How to create custom object?

How can we implement custom COM objects?
For example, I tried to implement IDWriteFontCollectionLoader like this (I overrride the CreateEnumeratorFromKey method):
from ctypes import byref, POINTER
from win32more import VoidPtr, UInt32
from win32more.Windows.Win32.Foundation import HRESULT, S_OK
from win32more.Windows.Win32.Graphics.DirectWrite import (
    DWRITE_FACTORY_TYPE_ISOLATED,
    DWriteCreateFactory,
    IDWriteFactory,
    IDWriteFontCollectionLoader,
    IDWriteFontFileEnumerator,
)

class CustomFontCollectionLoader(IDWriteFontCollectionLoader):

    def __init__(self):
        super(CustomFontCollectionLoader, self).__init__()

    def CreateEnumeratorFromKey(
            self,
            this: IDWriteFontCollectionLoader,
            factory: IDWriteFactory,
            collectionKey: VoidPtr,
            collectionKeySize: UInt32,
            fontFileEnumerator: POINTER(IDWriteFontFileEnumerator)
        )-> HRESULT:

        return S_OK

dwrite_factory = IDWriteFactory(own=True)
hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_ISOLATED, dwrite_factory._iid_, byref(dwrite_factory))

font_collection_loader = CustomFontCollectionLoader()
dwrite_factory.RegisterFontCollectionLoader(byref(font_collection_loader))

But, I get this exception, so I tought this wasn't the way to do it:
Traceback (most recent call last):
  File "c:\Users\moi15moi\Desktop\win32more test.py", line 34, in <module>
    dwrite_factory.RegisterFontCollectionLoader(byref(font_collection_loader))
  File "c:\Users\moi15moi\AppData\Local\Programs\Python\Python311\Lib\site-packages\win32more\__init__.py", line 451, in __call__
    return self._delegate(this, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\moi15moi\AppData\Local\Programs\Python\Python311\Lib\site-packages\win32more\__init__.py", line 468, in __call__
    result = self._delegate(this, *cargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: exception: access violation reading 0x0000000000000008

Try win32more._winrt.ComClass.  ComClass is an utility to define custom com class.
# ComClass usage
class MyComClass(ComClass, Interface1, Interface2, ...):
    # You need to implement methods of Interface1, Interface2 and etc....
    # ComClass has default implementation of IUnknown and IInspectable.
    ...

from ctypes import byref, POINTER
from win32more import VoidPtr, UInt32
from win32more.Windows.Win32.Foundation import HRESULT, S_OK
from win32more.Windows.Win32.Graphics.DirectWrite import (
    DWRITE_FACTORY_TYPE_ISOLATED,
    DWriteCreateFactory,
    IDWriteFactory,
    IDWriteFontCollectionLoader,
    IDWriteFontFileEnumerator,
)

from win32more._winrt import ComClass

class CustomFontCollectionLoader(ComClass, IDWriteFontCollectionLoader):

    def __init__(self):
        super(CustomFontCollectionLoader, self).__init__()

    def CreateEnumeratorFromKey(
            self,
            # this: IDWriteFontCollectionLoader,  <- not needed
            factory: IDWriteFactory,
            collectionKey: VoidPtr,
            collectionKeySize: UInt32,
            fontFileEnumerator: POINTER(IDWriteFontFileEnumerator)
        )-> HRESULT:

        return S_OK

dwrite_factory = IDWriteFactory(own=True)
hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_ISOLATED, dwrite_factory._iid_, byref(dwrite_factory))
assert hr == 0

font_collection_loader = CustomFontCollectionLoader()

# No need to use byref()
hr = dwrite_factory.RegisterFontCollectionLoader(font_collection_loader)
assert hr == 0

Note that win32more's com class is actually a com pointer.
# Python
p = IUnknown()

is equivalent to
// C
IUnknown *p;

Thanks!


[FFDC] OS logs during failures

Looking at the STC failure defects, these data seems pretty much needed

[x] cat /sys/firmware/opal/msglog
[x] lspci
[x] syscfg and
[x] lscpu

output and may be needed for OS FFDC collection.
Can we put something on this one. @ssombar Can u take a look those data, if it would be helpful if taken in general during failure.

looking at this now.

Thanks @ssombar  let me know if you need info on this

Two questions

Q1:  Are these commands for Ubuntu only, or do we need them for RH too?   I am thinking both
but need to confirm.
Q2:  I find no syscfg command.   lscfg perhaps?

Hmm .. now since most or our system is Ubuntu.. well u start with ubuntu with this comit, we will add check next commit to no-op or use corresponding available commands for it..

I will add
lspci
lscfg
lscpu
And I see   .../opal/msglog  is already collected by the FFDC tool:
#(CDT) 2017/08/14 13:14:13.315106 -    0.014113 - Issuing: cat /sys/firmware/opal/msglog

Gerrit review
https://gerrit.openbmc-project.xyz/5991

The commands are in Ubuntu and
(according to Google) also in RedHat.  If the command does not exist, the FFDC file is created anyway but its contents will say "Command <whatever_command_was_called_for_ffdc> not found.

Sweet.. lets gets those in. Thanks


no real need to use a temporary buffer

after some looking and thinking this buffer shuffling doesn't seem to serve any purpose.
I am doing a full rewrite of this code now, so this is just for review.
@baldersheim please review
@vekterli FYI

please take another look now after refactoring.


ModuleNotFoundError: No module named 'cityscapesscripts'

Thanks for your error report and we appreciate it a lot.
Checklist

I have searched related issues but cannot get the expected help.
The bug has not been fixed in the latest version.

Describe the bug
ModuleNotFoundError: No module named 'cityscapesscripts'
After I installed mmdetetetection V 1.1 according to the guide in a totally new environment, I ran train.py and reported the error above. It can't be solved by reinstalling mmdet completely for many times.
Reproduction

What command or script did you run?

python tools/train.py configs/atss/atss_r50_fpn_1x.py

Did you make any modifications on the code or config? Did you understand what you have modified?
I did not make any modifications on the code or config.

What dataset did you use?
My own dataset, in coco format, works well in previous versions of mmdet.
Environment

sys.platform: linux
Python: 3.6.7 | packaged by conda-forge | (default, Nov  6 2019, 16:19:42) [GCC 7.3.0]
CUDA available: True
CUDA_HOME: /usr/local/cuda
NVCC: Cuda compilation tools, release 10.0, V10.0.130
GPU 0: GeForce RTX 2080 Ti
GCC: gcc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609
PyTorch: 1.2.0+cu92
PyTorch compiling details: PyTorch built with:

GCC 7.3
Intel(R) Math Kernel Library Version 2019.0.4 Product Build 20190411 for Intel(R) 64 architecture applications
Intel(R) MKL-DNN v0.18.1 (Git Hash 7de7e5d02bf687f971e7668963649728356e0c20)
OpenMP 201511 (a.k.a. OpenMP 4.5)
NNPACK is enabled
CUDA Runtime 9.2
NVCC architecture flags: -gencode;arch=compute_35,code=sm_35;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,cod[1/1937]
-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_50,code=compute_50

CuDNN 7.6.2
Magma 2.5.1
Build settings: BLAS=MKL, BUILD_NAMEDTENSOR=OFF, BUILD_TYPE=Release, CXX_FLAGS= -Wno-deprecated -fvisibility-inlines-hidden -fopenmp
-DUSE_FBGEMM -DUSE_QNNPACK -O2 -fPIC -Wno-narrowing -Wall -Wextra -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno
-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-strict-overflo
w -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-error=pedantic -Wno-error=redundant-decls -Wno-erro
r=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trap
ping-math -Wno-stringop-overflow, DISABLE_NUMA=1, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, USE_CUDA=True, USE_EXCEPTION_PTR
=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON,

TorchVision: 0.4.0+cu92
OpenCV: 4.1.1
MMCV: 0.3.2
MMDetection: 1.1.0+51df8a9
MMDetection Compiler: GCC 5.4
MMDetection CUDA Compiler: 10.0

You may add addition that may be helpful for locating the problem, such as

How you installed PyTorch [e.g., pip, conda, source]
Other environment variables that may be related (such as $PATH, $LD_LIBRARY_PATH, $PYTHONPATH, etc.)

Error traceback
If applicable, paste the error trackback here.
Traceback (most recent call last):
  File "tools/train.py", line 14, in <module>
    from mmdet.apis import set_random_seed, train_detector
  File "/root/mmdetection/mmdet/apis/__init__.py", line 1, in <module>
    from .inference import (async_inference_detector, inference_detector,
  File "/root/mmdetection/mmdet/apis/inference.py", line 12, in <module>
    from mmdet.datasets.pipelines import Compose
  File "/root/mmdetection/mmdet/datasets/__init__.py", line 2, in <module>
    from .cityscapes import CityscapesDataset
  File "/root/mmdetection/mmdet/datasets/cityscapes.py", line 9, in <module>
    import cityscapesscripts.evaluation.evalInstanceLevelSemanticLabeling as CSEval

Bug fix
Hope to get a solution as soon as possible, thanks!

I can confirm this issue in the master branch. It wasn't an issue as of last Friday, 28FEB20; so, it must have been introduced by changes made over the weekend. I'm testing 1.1 now to see if this bug affects that branch as well.

@BigBaiNUE, I've checked and this bug appears to only affect the master branch not v1.1. I'm not sure how you installed mmdetection; however, I'd suggest using pip3 install -e<EMAIL_ADDRESS>

pip3 install -r requirements.txt

@BigBaiNUE, I've checked and this bug appears to only affect the master branch not v1.1. I'm not sure how you installed mmdetection; however, I'd suggest using pip3 install -e<EMAIL_ADDRESS>
Thank you for prompt reply. I installed it according to INSTALL.md steps. Your guidance is feasible, and now it works. Thx :-D

pip3 install -r requirements.txt

Thanks for reply.I completed this step and showed that the conditions were satisfied, but the problem still happened. It's solved by  using pip3 install -e<EMAIL_ADDRESS>

pip3 install -r requirements.txt

I solved by this. Thank U!!

Please read the documentation. It is stated in the docs that you need to run pip install cityscapesscripts and also convert the dataset format if you are working with cityscapes.


Change multi-source candidate point calculator to an acquisition optimizer

This PR converts the multi source candidate point calculator to an acquisition optimizer as it seems more natural and allows us to do batch multi-fidelity loops, see integration tests for an example.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Codecov Report

Merging #68 into develop will decrease coverage by 0.02%.
The diff coverage is 91.89%.

@@             Coverage Diff             @@
##           develop      #68      +/-   ##
===========================================
- Coverage    90.44%   90.42%   -0.03%
===========================================
  Files           59       60       +1
  Lines         1445     1451       +6
  Branches       156      156
===========================================
+ Hits          1307     1312       +5
- Misses         102      103       +1
  Partials        36       36

Impacted Files
Coverage Δ

emukit/core/loop/__init__.py
100% <100%> (ø)
:arrow_up:

emukit/core/loop/candidate_point_calculators.py
97.29% <100%> (+2.05%)
:arrow_up:

emukit/core/optimization/acquisition_optimizer.py
87.8% <75%> (-1.67%)
:arrow_down:

...optimization/multi_source_acquisition_optimizer.py
93.1% <93.1%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bad81bd...c9c7c26. Read the comment docs.


Type name confusion

The interpreter's type checker produces a clearly wrong error when the interpreted expression evaluates to a type synonym whose definition contains a qualified-imported type constructor whose native name is the same as the synonym.  See simple.zip for a minimal example (stack project).
Looking at the source, it seems to me that the problem is in the code
interpret :: (MonadInterpreter m, Typeable a) => String -> a -> m a
interpret expr wit = unsafeInterpret expr (show $ Data.Typeable.typeOf wit)

because Typeable's string representation doesn't give the fully qualified name of the type constructors.
Renaming the type synonym actually doesn't help, for the same reason: the compiler then complains that it can't find the imported type constructor.  You have to simply avoid using a type synonym altogether, since Typeable (of course) doesn't print the name of the synonym but its expansion.

This goes beyond my Haskell-fu, I'm afraid. If you believe you have a fix for this issue, feel free to add a test for this case and do the appropriate change, making sure all the tests pass.
/cc @simspace

I assume you meant to cc me, not my employer :)
I am familiar with that bug, I had to work around it in hawk. The fix would be to always quantify the type with its module name. That doesn't look too hard:
typeOf :: Typeable a => a -> TypeRep a
typeRepTyCon :: TypeRep a -> TyCon
tyConModule :: TyCon -> String

I'm so sorry - misread the github UI.

Hmm! This is more difficult than I though. Qualifying the type with its module name was easy, but that only helps if the type synonym resolves to a type from a module which is imported under its fully-qualified name.
@ryanreich's simple.zip 404s for me, but a simple reproducer is interpret "Data.Typeable.typeOf ()" (as :: Data.Typeable.TypeRep). In Data.Typeable, TypeRep is a type synonym for Data.Typeable.Internal.SomeTypeRep. That's bad news, because Data.Typeable.Internal is an internal module which we cannot import. So in this case, qualifying the type would make the situation worse: without the qualifier, we can still figure out that we can import Type.Reflection unqualified in order to bring SomeTypeRep into scope. With the qualifier... I guess we can still do it, using import Type.Reflection as Data.Typeable.Internal, but that's a pretty terrible hack.
So, if Foo is a type synonym for Bar.Foo but Bar is not imported (or worse, non-importable), then generating "expr :: Bar.Foo" instead of "expr :: Foo" doesn't help. Even if Bar is imported, some extra care is needed because it might be imported via import qualified Bar as B, in which case it's "expr :: B.Foo" which we have to generate.
Since it is generating the name of the type which is tricky, I thought I could work around the problem by generating "toDyn expr :: Dynamic", and then using fromDynamic to cast that to Foo outside of the interpreter. That works for my interpret "typeOf ()" (as :: TypeRep) reproducer, because TypeRep has a Typeable instance. Unfortunately, this breaks polymorphic expressions like interpret "id" (as :: Int -> Int) because while Int -> Int has a Typeable instance, a -> a does not. Generating "id :: Int -> Int" is what caused the interpreter to specialize a -> a to Int -> Int; if I generate toDyn id :: Dynamic, the specialization doesn't happen. In order to get that specialization to happen, I really need to generate the name of the type.
I really don't know how, though. One possible clue: I noticed that on hackage, when looking at the documentation for Data.Typeable, clicking on SomeTypeRep navigates to the documentation for Type.Reflection, not the documentation for Data.Typeable.Internal. How does haddock know, and can we do the same thing?

#88 is a duplicate of this, but more work has happened in that ticket than this one, so let's close this one in favor of #88.


Adds Proportional Service Provider Rewards HIP

This PR can be closed.  Abhay and I created a whole new file and PR.

Closed as requested.


Sync silently fails on java.lang.IllegalStateException: Duplicate key

Describe the bug
Sync no longer picks up new changes and silently fails without displaying any message in UI.
Log message:
--------- switch to main
07-28 06:59:22.620 24989 24989 I StorageUtils: /data/user/0/site.leos.apps.lespas/files is writable
07-28 06:59:22.627 24989 24989 I StorageUtils: /storage/emulated/0/Android/data/site.leos.apps.lespas/files is writable
07-28 06:59:22.628 24989 24989 I StorageUtils: /data/user/0/site.leos.apps.lespas/files is writable
07-28 06:59:22.628 24989 24989 I StorageUtils: /storage/emulated/0/Android/data/site.leos.apps.lespas/files is writable
07-28 06:59:22.633 24989 24989 I OsmDroid: Using tile source: Mapnik
07-28 06:59:22.638 24989 24989 I OsmDroid: Tile cache increased from 0 to 9
07-28 06:59:22.702 24989 24989 W View    : requestLayout() improperly called by android.widget.ScrollView{e83d410 VFED..... ......ID 11,11-896,404 #7f0a0062 app:id/background} during layout: running second layout pass
--------- switch to events
07-28 06:59:22.710 24989 24989 I viewroot_draw_event: [window=VRI[MainActivity],event=reportDrawFinished seqId=0]
--------- switch to main
07-28 06:59:22.762 24989 27456 E SyncAdapter: : java.lang.IllegalStateException: Duplicate key PXL_20240715_151327075.jpg (attempted merging values 1619227 and 1619223)
07-28 06:59:22.762 24989 27456 E SyncAdapter: : 	at java.util.stream.Collectors.duplicateKeyException(Collectors.java:135)
07-28 06:59:22.762 24989 27456 E SyncAdapter: : 	at java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Collectors.java:182)
07-28 06:59:22.762 24989 27456 E SyncAdapter: : 	at java.util.stream.Collectors$$ExternalSyntheticLambda1.accept(D8$$SyntheticClass:0)
07-28 06:59:22.762 24989 27456 E SyncAdapter: : 	at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
07-28 06:59:22.762 24989 27456 E SyncAdapter: : 	at java.util.Iterator.forEachRemaining(Iterator.java:133)
07-28 06:59:22.762 24989 27456 E SyncAdapter: : 	at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1845)
07-28 06:59:22.762 24989 27456 E SyncAdapter: : 	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513)
07-28 06:59:22.762 24989 27456 E SyncAdapter: : 	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:503)
07-28 06:59:22.762 24989 27456 E SyncAdapter: : 	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
07-28 06:59:22.762 24989 27456 E SyncAdapter: : 	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:236)
07-28 06:59:22.762 24989 27456 E SyncAdapter: : 	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:706)
07-28 06:59:22.762 24989 27456 E SyncAdapter: : 	at site.leos.apps.lespas.sync.SyncAdapter.syncRemoteChanges(SyncAdapter.kt:1164)
07-28 06:59:22.762 24989 27456 E SyncAdapter: : 	at site.leos.apps.lespas.sync.SyncAdapter.onPerformSync(SyncAdapter.kt:132)
07-28 06:59:22.762 24989 27456 E SyncAdapter: : 	at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:354)
07-28 06:59:22.816 24989 27461 D TrafficStats: tagSocket(204) with statsTag=0xffffffff, statsUid=-1
--------- switch to events
07-28 06:59:23.054 24989 25656 I jank_cuj_events_end_request: [CUJ Type=81,Unix Time Ns=1722149963053742s,Elapsed Time Ns=51988372768.729s,Uptime Time Ns=23310079925.728s]
--------- switch to main
07-28 06:59:24.174 24989 24989 W WindowOnBackDispatcher: sendCancelIfRunning: isInProgress=falsecallback=android.app.Dialog$$ExternalSyntheticLambda2@ced603f
07-28 06:59:24.182 24989 25019 D HWUI    : endAllActiveAnimators on 0xcdc0002ea200 (RippleDrawable) with handle 0xcc8afe167d20
07-28 06:59:24.596 24989 27461 E SyncAdapter: : java.lang.IllegalStateException: Duplicate key PXL_20240715_151327075.jpg (attempted merging values 1619227 and 1619223)
07-28 06:59:24.596 24989 27461 E SyncAdapter: : 	at java.util.stream.Collectors.duplicateKeyException(Collectors.java:135)
07-28 06:59:24.596 24989 27461 E SyncAdapter: : 	at java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Collectors.java:182)
07-28 06:59:24.596 24989 27461 E SyncAdapter: : 	at java.util.stream.Collectors$$ExternalSyntheticLambda1.accept(D8$$SyntheticClass:0)
07-28 06:59:24.596 24989 27461 E SyncAdapter: : 	at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
07-28 06:59:24.596 24989 27461 E SyncAdapter: : 	at java.util.Iterator.forEachRemaining(Iterator.java:133)
07-28 06:59:24.596 24989 27461 E SyncAdapter: : 	at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1845)
07-28 06:59:24.596 24989 27461 E SyncAdapter: : 	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513)
07-28 06:59:24.596 24989 27461 E SyncAdapter: : 	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:503)
07-28 06:59:24.596 24989 27461 E SyncAdapter: : 	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
07-28 06:59:24.596 24989 27461 E SyncAdapter: : 	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:236)
07-28 06:59:24.596 24989 27461 E SyncAdapter: : 	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:706)
07-28 06:59:24.596 24989 27461 E SyncAdapter: : 	at site.leos.apps.lespas.sync.SyncAdapter.syncRemoteChanges(SyncAdapter.kt:1164)
07-28 06:59:24.596 24989 27461 E SyncAdapter: : 	at site.leos.apps.lespas.sync.SyncAdapter.onPerformSync(SyncAdapter.kt:132)
07-28 06:59:24.596 24989 27461 E SyncAdapter: : 	at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:354)
07-28 06:59:24.686 24989 27462 D TrafficStats: tagSocket(213) with statsTag=0xffffffff, statsUid=-1

To Reproduce
I'm unsure how I ended up with 2 photos with what appears to be the same name.  In the LesPas client, I deleted both files, and then sync resumed.  I also saw the file was in Nextcloud twice, but with different file names.
Expected behavior

Ideally, root cause (duplicate file names) shouldn't be possible - but that's an issue for another day.
If sync 1 file fails, the sync process should continue syncing other files.  1 bad file shouldn't not take down the entire syncing process.
If sync fails - there should be a notification indicating which file failed and ideally options to fix it (or instructions to fix it).

Screenshots
n/a
Smartphone (please complete the following information):

Device: Pixel 8
OS: GrapheneOS (Android 14)
Version 20240716

Additional context
See logs above.

Agreed indeed. Les Pas will stop at any error it encounters during the sync process. A queue of failed uploads can be implemented in the future. Meanwhile, if the sync stops, you can see which file it stopped at in Setting->Sync status. However, there are no instructions on how to fix it in the current release, another area for improvement.


Obtain the time spent in different CPU frequencies

@credp: Just mentioning the idea we discussed to obtain the time spent in different CPU frequencies as a LISA API. I think this would be very useful. Not sure if this should be in combination with a devlib module modification to fetch the data?

Worth mentioning that there is already an API to do this from traces - trace.data_frame.cluster_frequency_residency, but I guess you're talking about using the kernels' own accounting as chris did.

Seems like LISA is already able to do that in the frequency analysis


What to put in the extras argument: tapes and other joys

Prepare for different output

[x] ForwardDiff.jl: work buffers (see #38) + mutable DiffResult
[x] ReverseDiff.jl: config and tape (see #45) + mutable DiffResult
[ ] FiniteDiff.jl: caches for gradient or jacobian
[ ] FastDifferentiation.jl: runtime-generated symbolic function
[ ] SparseDiffTools.jl: coloring pattern, for instance inside matrix-free operators

Prepare for same output, different tangent
Probably done by #72

See also #115


Cannot Query Private IPs through Loop

az feedback auto-generates most of the information requested below, as of CLI version 2.0.62

Describe the bug
Trying to loop through an array. Works well when query one machine, but when i loop through the array, the outputs says it cant be found
To Reproduce
Steps to reproduce the behavior.
for i in "${VM_NAME[@]}"; do \
   P_IP=$(az vm show -g $rg -n $i -d --query privateIps -otsv)
   echo $i $P_IP;
done

I get the following output:
The Resource 'Microsoft.Compute/virtualMachines/"VM-NAME"' under resource group 'Resource-GroupC' was not found.

Expected behavior
A clear and concise description of what you expected to happen.
IP1
IP2...
IPN
Environment summary
Install Method (e.g. pip, interactive script, apt-get, Docker, MSI, edge build) / CLI version (az --version) / OS version / Shell Type (e.g. bash, cmd.exe, Bash on Windows)
azure-cli (2.0.52)
MacOS

Additional context
Add any other context about the problem here.

It looks like your VM names are including double quotes.
'Microsoft.Compute/virtualMachines/"VM-NAME"'
Should be:
'Microsoft.Compute/virtualMachines/VM-NAME'
Your script will need to handle this.

But when i use the double quote in a single command it works?
az vm show -g $rg -n "VM_NAME" -d --query privateIps -otsv

When you do this:
az vm show -g $rg -n "VM_NAME" -d --query privateIps -otsv
Your shell is stripping off the quotes and only sending the string VM_NAME. You script is preserving the quotes and thus the CLI is seeing "VM_NAME".


PowerToys Run: "Clear the previous query" bug

ℹ Computer information

PowerToys version: v.0.21.1
PowerToy Utility: PowerToys Run
Running PowerToys as Admin: no
Windows build number: 19041.450

📝 Provide detailed reproduction steps (if any)

Go to PowerToys Run settings
Make sure that "Clear the previous query on launch" is checked
Open PowerToys Run
Type "windows"
Press ESC
Open PowerToys Run again

✔ Expected result
The past query should be cleared before it is rendered to avoid annoying blinking of past results.
❌ Actual result
The past query is not cleared before it is rendered so there is an annoying blinking of past results.
📷 Screenshots

similar to #5616

same issue as #5616


Backslashes mixed with quotes in @-escaped strings break syntax highlighting

Repro:
let foo = @"""\"""

This represents the string "" (including quotes).  It looks like Ionide interprets the backslash as escaping the closing quote, and then the subsequent pair of quotes as a second escaped quote, so the full quoted string is never closed. Subsequent lines of code are interpreted by ionide as part of the string.

Moved to https://github.com/ionide/ionide-fsgrammar/issues/3


Programmatically determine object type to update first time setup copy for warehouse

https://github.com/Snowflake-Labs/sfguide-native-apps-chairlift/blob/36802963b7ebf4813419308327d2da4a271d9d05/app/src/ui/references.py#L25
Is there a way to programmatically determine the object type and change the copy here accordingly? During first time setup, this copy says "table" when we are asking the consumer to bind a warehouse. So it ends up saying something like "select {warehouse} table". Very minor thing but might want to think about clarifying.

@sfc-gh-cgorrie @sfc-gh-melnacouzi – What do y'all think?


Prevent versioning for non-draftable items

I created a new content type that is not draftable.
But when i edit its content item using the default content management UI (Admin/Contents/Edit/ID) a new version of item will be created for each edition.
I think this is because of the following line in EditPOST method of Orchard.Core.Contents.Controllers.AdminController.
var contentItem = _contentManager.Get(id, VersionOptions.DraftRequired);
Why this method requires draft version for a non-draftable item?

Not draftable means there is no draft, just a published version, but historical version are still kept.
We added a different option in Orchard Core to handle this independently. You could port the code back to O1 if you need it?

@sebastienros Thank you for your reply. I will check the new option in Orchard Core.


preStorageInit alternative to Akita state management

Akita state management library has PersistState with:
preStorageUpdate(storeName: string, state: any): any;
preStoreUpdate(storeName: string, state: any, initialState: any): any;

Elf state persistState management, on the other hand, only has:
preStoreInit?: (value: StoreValue<S>) => Partial<StoreValue<S>>;
Storage init callback method is missing.
I am trying to persist two-way encoded sensitive data in local storage using persistState.

You're welcome to submit a PR :)


Update akka-actor, akka-stream-testkit, ... to 2.6.15

Updates

com.typesafe.akka:akka-actor
com.typesafe.akka:akka-stream-testkit
com.typesafe.akka:akka-testkit

from 2.6.5 to 2.6.15.
GitHub Release Notes - Version Diff
I'll automatically update this PR to resolve conflicts as long as you don't change it yourself.
If you'd like to skip this version, you can just close this PR. If you have any feedback, just mention me in the comments below.
Configure Scala Steward for your repository with a .scala-steward.conf file.
Have a fantastic day writing Scala!

Ignore future updates
Add this to your .scala-steward.conf file to ignore future updates of this dependency:
updates.ignore = [ { groupId = "com.typesafe.akka" } ]

labels: library-update, semver-patch

Superseded by #42.


Models located in tests.py are not created

Models that exists only for testing purpose are not created when tests running by django_nose
Problem exists because setup_databases called before any test module have been imported.
This could be fixed by moving setup_databases call into prepareTest in Plugin

@dcramer: I tried out master with my models-in-tests.py project and they're not picked up.
I can't find anything with grepping and reading the readme that suggests how to set it up. Separate app? But that means I have to put it in the INSTALLED_APPS list (which I don't want). And I can't find something like @rozza's TEST_INSTALLED_APPS.

Guys, do we have a fix for this now? Again reiterating the question -
Can we create Model Class for testing without putting it in INSTALLED_APPS, and execute/test it successfully?

Reopening since many people struggle with this.
For my own reusable apps, I add a sample app and project to the repo, and run django-nose against the sample project.  See the django-nose repo, and https://github.com/jwhitlock/drf-cached-instances.
Because there are work arounds, this feels like a feature request, not a bug.

If this is considered a feature request, than perhaps the documentation should be updated.
The docs specify that this behavior works while clearly there are some caveats:
http://django-nose.readthedocs.org/en/latest/usage.html#test-only-models

Is there any traction on this as still getting the error. The docs say it's possible. Normal django tests do it. It's clearly not a feature but a bug as it goes against the documentation and expected behaviour.


Addresses https://github.com/photonstorm/phaser/issues/5697

This diff adds:

type support to createFromObjects. See https://doc.mapeditor.org/en/stable/manual/custom-properties/#typed-tiles for the description in Tiled; this is currently not supported as a parameter, and its usage is documented within the diff.
createFromObjects will also examine the tileset. As per the above link, created objects are supposed to inherit properties from the tile with the same gid, but Phaser doesn't do that right now. After this diff it optionally will, by passing an additional parameter to createFromObjects.

NOTE: I'd be very happy to make this a default behavior, but that's somewhat backwards breaking

createFromObjects will attempt to use the same texture and frame as Tiled when creating the object. This will behave poorly if there is no such frame (for instance, if the texture were loaded with this.load.image instead of this.load.spritesheet, or using different geometry. However, the current behavior draws missingimage, so this is a strong improvement.

👍


mesen: init at 2.0.0-unstable-2024-10-17

Description of changes
Closes https://github.com/NixOS/nixpkgs/issues/301132
Core build time is ~10mins for me.
I only tested SMB for the NES.

Things done

Built on platform(s)

[x] x86_64-linux
[ ] aarch64-linux
[ ] x86_64-darwin
[ ] aarch64-darwin

For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)

[ ] sandbox = relaxed
[ ] sandbox = true

[ ] Tested, as applicable:

NixOS test(s) (look inside nixos/tests)
and/or package tests
or, for functions and "core" functionality, tests in lib/tests or pkgs/test
made sure NixOS tests are linked to the relevant packages

[ ] Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
[ ] Tested basic functionality of all binary files (usually in ./result/bin/)
24.05 Release Notes (or backporting 23.05 and 23.11 Release notes)

[ ] (Package updates) Added a release notes entry if the change is major or breaking
[ ] (Module updates) Added a release notes entry if the change is significant
[ ] (Module addition) Added a release notes entry if adding a new NixOS module

[x] Fits CONTRIBUTING.md.

Add a :+1: reaction to pull requests you find important.

Result of nixpkgs-review pr 301666 run on x86_64-linux 1

1 package built:

mesen

Could this be eligible for the unstable updater? https://github.com/NixOS/nixpkgs/blob/master/pkgs/common-updater/unstable-updater.nix

Could this be eligible for the unstable updater? https://github.com/NixOS/nixpkgs/blob/master/pkgs/common-updater/unstable-updater.nix

Probably not, since this package needs a generated deps.nix file for dotnet packages.

What's currently pending for this one? I could definitely use this package for NES debugging, so if there's anything I can help with to move this forwards, please let me know.

I'm getting this error
❯ nix run github:TomaSajt/nixpkgs/mesen2#mesen
error: builder for '/nix/store/kjwrck5dfaig3bvnxqgw8qxqzm9yami5-mesen-2.0.0-unstable-2024-06-01.drv' failed with exit code 1;
       last 10 log lines:
       > patching file UI/Config/ConfigManager.cs
       > patching file UI/Program.cs
       > patching file UI/UI.csproj
       > Running phase: configureNuget
       > Running phase: updateAutotoolsGnuConfigScriptsPhase
       > Running phase: configurePhase
       > Executing dotnetConfigureHook
       >   Determining projects to restore...
       > /build/source/UI/UI.csproj : error NU1301: Unable to load the service index for source https://nuget-feed-nightly.avaloniaui.net/v3/index.json.
       >   Failed to restore /build/source/UI/UI.csproj (in 5.5 sec).
       For full logs, run 'nix log /nix/store/kjwrck5dfaig3bvnxqgw8qxqzm9yami5-mesen-2.0.0-unstable-2024-06-01.drv'.

I'm getting this error
❯ nix run github:TomaSajt/nixpkgs/mesen2#mesen
error: builder for '/nix/store/kjwrck5dfaig3bvnxqgw8qxqzm9yami5-mesen-2.0.0-unstable-2024-06-01.drv' failed with exit code 1;
       last 10 log lines:
       > patching file UI/Config/ConfigManager.cs
       > patching file UI/Program.cs
       > patching file UI/UI.csproj
       > Running phase: configureNuget
       > Running phase: updateAutotoolsGnuConfigScriptsPhase
       > Running phase: configurePhase
       > Executing dotnetConfigureHook
       >   Determining projects to restore...
       > /build/source/UI/UI.csproj : error NU1301: Unable to load the service index for source https://nuget-feed-nightly.avaloniaui.net/v3/index.json.
       >   Failed to restore /build/source/UI/UI.csproj (in 5.5 sec).
       For full logs, run 'nix log /nix/store/kjwrck5dfaig3bvnxqgw8qxqzm9yami5-mesen-2.0.0-unstable-2024-06-01.drv'.

Yes, sorry about that, I should have probably put the PR into draft.
I'm still working on updating to the latest version but I'm having some issues. I'll try to fix this current one for now.
I'll be away this week but I'll try to do what I can.

Updated to the latest commit before update to Avalonia 11.1, which breaks the build (duplicate asset errors and elements just not compiling). I have no idea how to use Avalonia or why it broke, so this is as far as I could go for now.

Now that https://github.com/NixOS/nixpkgs/pull/340493 is fixed I could update to a later commit more easily.

I'm getting a problem when starting up the program, and i don't know where else to ask...
When trying to start the program, the following gets printed out and the program crashes:
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](List`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at Avalonia.Platform.Internal.AssemblyDescriptor..ctor(Assembly assembly)
   at Avalonia.Platform.StandardAssetLoader..ctor(IAssemblyDescriptorResolver resolver, Assembly assembly)
   at Avalonia.Platform.StandardAssetLoader..ctor(Assembly assembly)
   at Avalonia.Platform.StandardRuntimePlatformServices.Register(Assembly assembly)
   at Avalonia.AppBuilder.<UseStandardRuntimePlatformSubsystem>b__68_0()
   at Avalonia.AppBuilder.SetupUnsafe()
   at Avalonia.AppBuilder.Setup()
   at Avalonia.AppBuilder.SetupWithLifetime(IApplicationLifetime lifetime)
   at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime(AppBuilder builder, String[] args, ShutdownMode shutdownMode)
   at Mesen.Program.Main(String[] args) in /build/source/UI/Program.cs:line 58
Aborted (core dumped)

I really need this to work as this is the only program pvsneslib supports for its debug files...

I'm getting a problem when starting up the program, and i don't know where else to ask...
When trying to start the program, the following gets printed out and the program crashes:
Unhandled exception. System.ArgumentException: An item with the same key has already been added. Key: /Assets/NesIcon.png
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](List`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at Avalonia.Platform.Internal.AssemblyDescriptor..ctor(Assembly assembly)
   at Avalonia.Platform.StandardAssetLoader..ctor(IAssemblyDescriptorResolver resolver, Assembly assembly)
   at Avalonia.Platform.StandardAssetLoader..ctor(Assembly assembly)
   at Avalonia.Platform.StandardRuntimePlatformServices.Register(Assembly assembly)
   at Avalonia.AppBuilder.<UseStandardRuntimePlatformSubsystem>b__68_0()
   at Avalonia.AppBuilder.SetupUnsafe()
   at Avalonia.AppBuilder.Setup()
   at Avalonia.AppBuilder.SetupWithLifetime(IApplicationLifetime lifetime)
   at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime(AppBuilder builder, String[] args, ShutdownMode shutdownMode)
   at Mesen.Program.Main(String[] args) in /build/source/UI/Program.cs:line 58
Aborted (core dumped)

I really need this to work as this is the only program pvsneslib supports for its debug files...
EDIT: I'm using the following to enter a nix shell with Mesen on the path:
{pkgs ? import <nixpkgs>{}, ...}:
let
mesen = pkgs.callPackage ./mesen.nix {};
in
pkgs.mkShell{
  packages = [mesen];
}

You shouldn't be using your own <nixpkgs>, since it's missing crucial fixes for the AvaloniaUI ecosystem.
I advise you update your <nixpkgs> channel to a more recent version
or that you replace the <nixpkgs> expression with (builtins.fetchTarball { url = "https://github.com/TomaSajt/nixpkgs/archive/mesen2.tar.gz"; sha256 = ""; })

that fixed it! thank you

Doesn't build for me:
Executing dotnetConfigureHook
  Determining projects to restore...
/build/source/UI/UI.csproj : error NU1102: Unable to find package Microsoft.NETCore.App.Host.win-x64 with version (= 8.0.10)
/build/source/UI/UI.csproj : error NU1102:   - Found 1 version(s) in _nix [ Nearest version: 8.0.8 ]
  Failed to restore /build/source/UI/UI.csproj (in 254 ms).

Result of nixpkgs-review pr 301666 run on x86_64-linux 1

1 package failed to build:

mesen

@corngood could you help with this? I'm not exactly sure how these AppHost things work...

I think you just need:
diff --git a/pkgs/by-name/me/mesen/package.nix b/pkgs/by-name/me/mesen/package.nix
index a5fd5a47f1a2..bc8d722799c3 100644
--- a/pkgs/by-name/me/mesen/package.nix
+++ b/pkgs/by-name/me/mesen/package.nix
@@ -37,6 +37,10 @@ buildDotnetModule rec {

   projectFile = [ "UI/UI.csproj" ];

+  dotnetFlags = [
+    "-p:RuntimeIdentifier=${dotnetCorePackages.systemToDotnetRid clangStdenv.hostPlatform.system}"
+  ];
+
   executables = [ "Mesen" ];

   nugetDeps = ./deps.nix;

To stop it from overriding the RID to windows.  That's a property they set in their makefile.  You should then re-run fetch-deps, which should remove Microsoft.NETCore.App.Host.win-x64 from the lock file.

nixpkgs-review result
Generated using nixpkgs-review.
Command: nixpkgs-review pr 301666

x86_64-linux

:white_check_mark: 1 package built:

mesen

Seems like updating broke the non x86-64-linux builds. Will look into it

Reverted to the working version, for now.

ofborg build failed on aarch64-linux
       > /nix/store/nrg6lg8ihkav4g129q37h4h7bminng0d-dotnet-sdk-8.0.403/sdk/8.0.403/Microsoft.Common.CurrentVersion.targets(5034,5): error MSB3021: Unable to copy file "/build/nuget.uWn0cQ/fallback/system.reactive/6.0.0/lib/net6.0/System.Reactive.dll" to "/bin/linux-arm64/Release/System.Reactive.dll". Access to the path '/bin/linux-arm64' is denied. [/build/source/UI/UI.csproj]
       > /nix/store/nrg6lg8ihkav4g129q37h4h7bminng0d-dotnet-sdk-8.0.403/sdk/8.0.403/Microsoft.Common.CurrentVersion.targets(5034,5): error MSB3021: Unable to copy file "/build/nuget.uWn0cQ/fallback/tmds.dbus.protocol/0.16.0/lib/net6.0/Tmds.DBus.Protocol.dll" to "/bin/linux-arm64/Release/Tmds.DBus.Protocol.dll". Access to the path '/bin/linux-arm64' is denied. [/build/source/UI/UI.csproj]
       > /nix/store/nrg6lg8ihkav4g129q37h4h7bminng0d-dotnet-sdk-8.0.403/sdk/8.0.403/Microsoft.Common.CurrentVersion.targets(5034,5): error MSB3021: Unable to copy file "/build/nuget.uWn0cQ/fallback/system.io.pipelines/6.0.0/lib/net6.0/System.IO.Pipelines.dll" to "/bin/linux-arm64/Release/System.IO.Pipelines.dll". Access to the path '/bin/linux-arm64' is denied. [/build/source/UI/UI.csproj]
       > /nix/store/nrg6lg8ihkav4g129q37h4h7bminng0d-dotnet-sdk-8.0.403/sdk/8.0.403/Microsoft.Common.CurrentVersion.targets(5034,5): error MSB3021: Unable to copy file "/build/nuget.uWn0cQ/fallback/harfbuzzsharp.nativeassets.linux/<IP_ADDRESS>/runtimes/linux-arm64/native/libHarfBuzzSharp.so" to "/bin/linux-arm64/Release/libHarfBuzzSharp.so". Access to the path '/bin/linux-arm64' is denied. [/build/source/UI/UI.csproj]
       > /nix/store/nrg6lg8ihkav4g129q37h4h7bminng0d-dotnet-sdk-8.0.403/sdk/8.0.403/Microsoft.Common.CurrentVersion.targets(5034,5): error MSB3021: Unable to copy file "/build/nuget.uWn0cQ/fallback/skiasharp.nativeassets.linux/2.88.8/runtimes/linux-arm64/native/libSkiaSharp.so" to "/bin/linux-arm64/Release/libSkiaSharp.so". Access to the path '/bin/linux-arm64' is denied. [/build/source/UI/UI.csproj]
       >     1 Warning(s)
       >     43 Error(s)
       >
       > Time Elapsed 00:00:39.23

Rebased, updated to use deps.json and added aarch64-linux to meta.badPlatforms

nixpkgs-review result
Generated using nixpkgs-review.
Command: nixpkgs-review pr 301666

x86_64-linux

:white_check_mark: 1 package built:

mesen

@ofborg build mesen

@ofborg build mesen


Add contribution to Proof_Of_ContributionSnapshot4.md

[!NOTE]
UPDATE 30.05:
Updated the weights based on Snapshot 5: reduced by 35% based on the new Implied value of a Weight and added 6% for contribution this month. Resubmitted PR for Snaphot 5: https://github.com/MorpheusAIs/Docs/pull/287.

Added contributions for:

https://github.com/MorpheusAIs/MRC/pull/51

Draft MRC34, beginning of active research and discussion of Smart Agent Domains implementation with the team. Additional docs.

https://github.com/MorpheusAIs/MRC/pull/52

Fixes in other MRCs

https://github.com/MorpheusAIs/Docs/pull/245

Fix MRC21 link in docs

https://github.com/MorpheusAIs/Docs/pull/239, https://github.com/MorpheusAIs/Docs/pull/246, https://github.com/MorpheusAIs/Docs/issues/199, https://github.com/MorpheusAIs/Docs/pull/223, https://github.com/MorpheusAIs/Docs/pull/205

Some assistance with PRs/Issues

And additionally fixed amm broken link in this PR.

This PR was not closed or merged, so it was resubmitted for Snapshot 5: https://github.com/MorpheusAIs/Docs/pull/287.

The MRC is not accepted, developed or delivered yet. Please re submit next month.
The rest of these documents have conflicts.
I'd suggest making much smaller pull requests with less content to be in conflict and for easier review. Thanks.

The MRC is not accepted, developed or delivered yet. Please re submit next month. The rest of these documents have conflicts. I'd suggest making much smaller pull requests with less content to be in conflict and for easier review. Thanks.

Thanks for the advice. Can you please clarify which conflicts you are referring to?